diff --git a/docs/docs/gatsby-link.md b/docs/docs/gatsby-link.md index 91ae392bb7eca..06e1196a15a0c 100644 --- a/docs/docs/gatsby-link.md +++ b/docs/docs/gatsby-link.md @@ -169,7 +169,7 @@ const AreYouSureLink = () => ( Video hosted on [egghead.io][egghead]. -Sometimes you need to navigate to pages programatically, such as during form submissions. In these cases, `Link` won’t work. +Sometimes you need to navigate to pages programmatically, such as during form submissions. In these cases, `Link` won’t work. _**Note:** `navigate` was previously named `navigateTo`. `navigateTo` is deprecated in Gatsby v2 and will be removed in the next major release._ diff --git a/examples/using-typescript/src/utils/typography.d.ts b/examples/using-typescript/src/utils/typography.d.ts index 7288da639950f..7c339a30174b9 100644 --- a/examples/using-typescript/src/utils/typography.d.ts +++ b/examples/using-typescript/src/utils/typography.d.ts @@ -1 +1 @@ -export declare const rhythm: (a: number) => number; +export declare const rhythm: (a: number) => number diff --git a/package.json b/package.json index 26b29402db60b..4d3eabdb70454 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "postmarkdown": "prettier --write \"starters/**/*.md\"", "plop": "plop", "prebootstrap": "yarn", - "prettier": "prettier \"**/*.{md,css,scss,yaml,yml}\"", + "prettier": "prettier \"**/*.{md,css,scss,yaml,yml,ts}\"", "publish": "node scripts/check-publish-access && lerna publish", "publish-canary": "lerna publish --canary --yes", "publish-next": "lerna publish --npm-tag=next --bump=prerelease", diff --git a/packages/gatsby-image/index.d.ts b/packages/gatsby-image/index.d.ts index 4b10f7392f1e8..910ba9ef8059c 100644 --- a/packages/gatsby-image/index.d.ts +++ b/packages/gatsby-image/index.d.ts @@ -32,7 +32,7 @@ interface GatsbyImageProps { alt?: string className?: string | object critical?: boolean - crossOrigin?: string | boolean; + crossOrigin?: string | boolean style?: object imgStyle?: object placeholderStyle?: object diff --git a/packages/gatsby-link/index.d.ts b/packages/gatsby-link/index.d.ts index 321a4af7f503c..f3134e91751ff 100644 --- a/packages/gatsby-link/index.d.ts +++ b/packages/gatsby-link/index.d.ts @@ -2,23 +2,56 @@ import * as React from "react" import { NavigateFn, LinkProps } from "@reach/router" export interface GatsbyLinkProps extends LinkProps { + /** A class to apply when this Link is active */ activeClassName?: string + /** Inline styles for when this Link is active */ activeStyle?: object innerRef?: Function onClick?: (event: React.MouseEvent) => void + /** Class the link as highlighted if there is a partial match via a the `to` being prefixed to the current url */ partiallyActive?: boolean + /** Used to declare that this link replaces the current URL in history with the target */ replace?: boolean + /** The URL you want to link to */ to: string } +/** + * This component is intended _only_ for links to pages handled by Gatsby. For links to pages on other + * domains or pages on the same domain not handled by the current Gatsby site, use the normal `` element. + */ export default class GatsbyLink extends React.Component< GatsbyLinkProps, any > {} + +/** + * Sometimes you need to navigate to pages programmatically, such as during form submissions. In these + * cases, `Link` won’t work. + */ export const navigate: NavigateFn + +/** + * It is common to host sites in a sub-directory of a site. Gatsby lets you set the path prefix for your site. + * After doing so, Gatsby's `` component will automatically handle constructing the correct URL in + * development and production + */ export const withPrefix: (path: string) => string -// TODO: Remove navigateTo, push & replace for Gatsby v3 +/** + * @deprecated + * TODO: Remove for Gatsby v3 + */ export const push: (to: string) => void + +/** + * @deprecated + * TODO: Remove for Gatsby v3 + */ export const replace: (to: string) => void + +/** + * @deprecated + * TODO: Remove for Gatsby v3 + */ export const navigateTo: (to: string) => void diff --git a/packages/gatsby-plugin-google-analytics/index.d.ts b/packages/gatsby-plugin-google-analytics/index.d.ts index a920452297ee1..81b6f71833b03 100644 --- a/packages/gatsby-plugin-google-analytics/index.d.ts +++ b/packages/gatsby-plugin-google-analytics/index.d.ts @@ -8,4 +8,3 @@ export class OutboundLink extends React.Component< OutboundLinkProps & React.HTMLProps, any > {} - diff --git a/packages/gatsby-plugin-google-gtag/index.d.ts b/packages/gatsby-plugin-google-gtag/index.d.ts index a920452297ee1..81b6f71833b03 100644 --- a/packages/gatsby-plugin-google-gtag/index.d.ts +++ b/packages/gatsby-plugin-google-gtag/index.d.ts @@ -8,4 +8,3 @@ export class OutboundLink extends React.Component< OutboundLinkProps & React.HTMLProps, any > {} - diff --git a/packages/gatsby-source-filesystem/index.d.ts b/packages/gatsby-source-filesystem/index.d.ts new file mode 100644 index 0000000000000..d710142241cb5 --- /dev/null +++ b/packages/gatsby-source-filesystem/index.d.ts @@ -0,0 +1,84 @@ +import { Node, Store, Cache } from "gatsby" + +/** + * @see https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=files#createfilepath + */ +export function createFilePath(args: CreateFilePathArgs): string + +/** + * @see https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=files#createremotefilenode + */ +export function createRemoteFileNode( + args: CreateRemoteFileNodeArgs +): FileSystemNode + +export interface CreateFilePathArgs { + node: Node + getNode: Function + basePath?: string + trailingSlash?: boolean +} + +export interface CreateRemoteFileNodeArgs { + url: string + store: Store + cache: Cache + createNode: Function + createNodeId: Function + parentNodeId?: string + auth?: { + htaccess_user: string + htaccess_pass: string + } + httpHeaders?: object + ext?: string + name?: string +} + +export interface FileSystemNode extends Node { + absolutePath: string + accessTime: string + birthTime: Date + changeTime: string + extension: string + modifiedTime: string + prettySize: string + relativeDirectory: string + relativePath: string + sourceInstanceName: string + + // parsed path typings + base: string + dir: string + ext: string + name: string + root: string + + // stats + atime: Date + atimeMs: number + birthtime: Date + birthtimeMs: number + ctime: Date + ctimeMs: number + gid: number + mode: number + mtime: Date + mtimeMs: number + size: number + uid: number +} + +export interface FileSystemConfig { + resolve: "gatsby-source-filesystem" + options: FileSystemOptions +} + +/** + * @see https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=filesy#options + */ +interface FileSystemOptions { + name: string + path: string + ignore?: string[] +} diff --git a/packages/gatsby-source-filesystem/package.json b/packages/gatsby-source-filesystem/package.json index dcecff9067faf..180684d8612bf 100644 --- a/packages/gatsby-source-filesystem/package.json +++ b/packages/gatsby-source-filesystem/package.json @@ -43,5 +43,6 @@ "build": "babel src --out-dir . --ignore **/__tests__", "prepare": "cross-env NODE_ENV=production npm run build", "watch": "babel -w src --out-dir . --ignore **/__tests__" - } + }, + "types": "index.d.ts" } diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts index 43d9af85eb1e0..f7aa75690c40b 100644 --- a/packages/gatsby/index.d.ts +++ b/packages/gatsby/index.d.ts @@ -13,6 +13,30 @@ export { withPrefix, } from "gatsby-link" +export interface StaticQueryProps { + query: any + render?: RenderCallback + children?: RenderCallback +} + +export const useStaticQuery: (query: any) => TData + +export const parsePath: (path: string) => WindowLocation + +export interface PageRendererProps { + location: WindowLocation +} + +/** + * PageRenderer's constructor [loads the page resources](https://www.gatsbyjs.org/docs/production-app/#load-page-resources) for the path. + * + * On first load though, these will have already been requested from the server by `` in the page's original HTML (see [Link Preloads](https://www.gatsbyjs.org/docs/how-code-splitting-works/#construct-link-and-script-tags-for-current-page) in HTML Generation Docs). + * The loaded page resources includes the imported component, with which we create the actual page component using [React.createElement()](https://reactjs.org/docs/react-api.html). This element is returned to our RouteHandler which hands it off to Reach Router for rendering. + * + * @see https://www.gatsbyjs.org/docs/production-app/#page-rendering + */ +export class PageRenderer extends React.Component {} + type RenderCallback = (data: any) => React.ReactNode export interface StaticQueryProps { @@ -21,10 +45,25 @@ export interface StaticQueryProps { children?: RenderCallback } -export class StaticQuery extends React.Component {} +/** + * StaticQuery can do most of the things that page query can, including fragments. The main differences are: + * + * - page queries can accept variables (via `pageContext`) but can only be added to _page_ components + * - StaticQuery does not accept variables (hence the name "static"), but can be used in _any_ component, including pages + * - StaticQuery does not work with raw React.createElement calls; please use JSX, e.g. `` + * + * @see https://www.gatsbyjs.org/docs/static-query/ + */ -export const useStaticQuery: (query: any) => TData +export class StaticQuery extends React.Component {} +/** + * graphql is a tag function. Behind the scenes Gatsby handles these tags in a particular way + * + * During the Gatsby build process, GraphQL queries are pulled out of the original source for parsing. + * + * @see https://www.gatsbyjs.org/docs/page-query#how-does-the-graphql-tag-work + */ export const graphql: (query: TemplateStringsArray) => void /** @@ -33,19 +72,31 @@ export const graphql: (query: TemplateStringsArray) => void * @see https://www.gatsbyjs.org/docs/gatsby-config/ */ export interface GatsbyConfig { - siteMetadata?: Record; - plugins?: Array; - }>; - pathPrefix?: string; - polyfill?: boolean; - mapping?: Record; + /** When you want to reuse common pieces of data across the site (for example, your site title), you can store that here. */ + siteMetadata?: Record + /** Plugins are Node.js packages that implement Gatsby APIs. The config file accepts an array of plugins. Some plugins may need only to be listed by name, while others may take options. */ + plugins?: Array< + | string + | { + resolve: string + options: Record + } + > + /** It’s common for sites to be hosted somewhere other than the root of their domain. Say we have a Gatsby site at `example.com/blog/`. In this case, we would need a prefix (`/blog`) added to all paths on the site. */ + pathPrefix?: string + /** Gatsby uses the ES6 Promise API. Because some browsers don't support this, Gatsby includes a Promise polyfill by default. If you'd like to provide your own Promise polyfill, you can set `polyfill` to false.*/ + polyfill?: boolean + mapping?: Record + /** + * Setting the proxy config option will tell the develop server to proxy any unknown requests to your specified server. + * @see https://www.gatsbyjs.org/docs/api-proxy/ + * */ proxy?: { - prefix: string; - url: string; - }; - developMiddleware?(app: Application): void; + prefix: string + url: string + } + /** Sometimes you need more granular/flexible access to the development server. Gatsby exposes the Express.js development server to your site’s gatsby-config.js where you can add Express middleware as needed. */ + developMiddleware?(app: Application): void } /** @@ -54,77 +105,272 @@ export interface GatsbyConfig { * @see https://www.gatsbyjs.org/docs/node-apis/ */ export interface GatsbyNode { - createPages?(args: CreatePagesArgs, options: PluginOptions): any; - createPages?(args: CreatePagesArgs, options: PluginOptions): Promise; - createPages?(args: CreatePagesArgs, options: PluginOptions, callback: PluginCallback): void; - - createPagesStatefully?(args: CreatePagesArgs, options: PluginOptions): any; - createPagesStatefully?(args: CreatePagesArgs, options: PluginOptions): Promise; - createPagesStatefully?(args: CreatePagesArgs, options: PluginOptions, callback: PluginCallback): void; - - generateSideEffects?(args: NodePluginArgs, options: PluginOptions): any; - generateSideEffects?(args: NodePluginArgs, options: PluginOptions): Promise; - generateSideEffects?(args: NodePluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onCreateBabelConfig?(args: CreateBabelConfigArgs, options: PluginOptions): any; - onCreateBabelConfig?(args: CreateBabelConfigArgs, options: PluginOptions): Promise; - onCreateBabelConfig?(args: CreateBabelConfigArgs, options: PluginOptions, callback: PluginCallback): void; - - onCreateDevServer?(args: CreateDevServerArgs, options: PluginOptions): any; - onCreateDevServer?(args: CreateDevServerArgs, options: PluginOptions): Promise; - onCreateDevServer?(args: CreateDevServerArgs, options: PluginOptions, callback: PluginCallback): void; - - onCreateNode?(args: CreateNodeArgs, options: PluginOptions): any; - onCreateNode?(args: CreateNodeArgs, options: PluginOptions): Promise; - onCreateNode?(args: CreateNodeArgs, options: PluginOptions, callback: PluginCallback): void; - - onCreatePage?(args: CreatePageArgs, options: PluginOptions): any; - onCreatePage?(args: CreatePageArgs, options: PluginOptions): Promise; - onCreatePage?(args: CreatePageArgs, options: PluginOptions, callback: PluginCallback): void; - - onCreateWebpackConfig?(args: CreateWebpackConfigArgs, options: PluginOptions): any; - onCreateWebpackConfig?(args: CreateWebpackConfigArgs, options: PluginOptions): Promise; - onCreateWebpackConfig?(args: CreateWebpackConfigArgs, options: PluginOptions, callback: PluginCallback): void; - - onPostBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions): any; - onPostBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions): Promise; - onPostBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onPostBuild?(args: NodePluginArgs, options: PluginOptions): any; - onPostBuild?(args: NodePluginArgs, options: PluginOptions): Promise; - onPostBuild?(args: NodePluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onPreBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions): any; - onPreBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions): Promise; - onPreBootstrap?(args: ParentSpanPluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onPreBuild?(args: NodePluginArgs, options: PluginOptions): any; - onPreBuild?(args: NodePluginArgs, options: PluginOptions): Promise; - onPreBuild?(args: NodePluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onPreExtractQueries?(args: ParentSpanPluginArgs, options: PluginOptions): any; - onPreExtractQueries?(args: ParentSpanPluginArgs, options: PluginOptions): Promise; - onPreExtractQueries?(args: ParentSpanPluginArgs, options: PluginOptions, callback: PluginCallback): void; - - onPreInit?(args: ParentSpanPluginArgs, options: PluginOptions): any; - onPreInit?(args: ParentSpanPluginArgs, options: PluginOptions): Promise; - onPreInit?(args: ParentSpanPluginArgs, options: PluginOptions, callback: PluginCallback): void; - - preprocessSource?(args: PreprocessSourceArgs, options: PluginOptions): any; - preprocessSource?(args: PreprocessSourceArgs, options: PluginOptions): Promise; - preprocessSource?(args: PreprocessSourceArgs, options: PluginOptions, callback: PluginCallback): void; - - resolvableExtensions?(args: ResolvableExtensionsArgs, options: PluginOptions): any; - resolvableExtensions?(args: ResolvableExtensionsArgs, options: PluginOptions): Promise; - resolvableExtensions?(args: ResolvableExtensionsArgs, options: PluginOptions, callback: PluginCallback): void; - - setFieldsOnGraphQLNodeType?(args: SetFieldsOnGraphQLNodeTypeArgs, options: PluginOptions): any; - setFieldsOnGraphQLNodeType?(args: SetFieldsOnGraphQLNodeTypeArgs, options: PluginOptions): Promise; - setFieldsOnGraphQLNodeType?(args: SetFieldsOnGraphQLNodeTypeArgs, options: PluginOptions, callback: PluginCallback): void; - - sourceNodes?(args: SourceNodesArgs, options: PluginOptions): any; - sourceNodes?(args: SourceNodesArgs, options: PluginOptions): Promise; - sourceNodes?(args: SourceNodesArgs, options: PluginOptions, callback: PluginCallback): void; + /** + * Tell plugins to add pages. This extension point is called only after the initial + * sourcing and transformation of nodes plus creation of the GraphQL schema are + * complete so you can query your data in order to create pages. + * + * @see https://www.gatsbyjs.org/docs/node-apis/#createPages + */ + createPages?( + args: CreatePagesArgs & { traceId: "initial-createPages" }, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Like `createPages` but for plugins who want to manage creating and removing + * pages themselves in response to changes in data *not* managed by Gatsby. + * Plugins implementing `createPages` will get called regularly to recompute + * page information as Gatsby's data changes but those implementing + * `createPagesStatefully` will not. + * + * An example of a plugin that uses this extension point is the plugin + * [gatsby-plugin-page-creator](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-page-creator) + * which monitors the `src/pages` directory for the adding and removal of JS + * pages. As its source of truth, files in the pages directory, is not known by + * Gatsby, it needs to keep its own state about its world to know when to + * add and remove pages. + */ + createPagesStatefully?( + args: CreatePagesArgs & { traceId: "initial-createPagesStatefully" }, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Let plugins extend/mutate the site's Babel configuration. + * This API will change before 2.0 as it needs still to be converted to use + * Redux actions. + */ + onCreateBabelConfig?( + args: CreateBabelConfigArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Run when gatsby develop server is started, its useful to add proxy and middleware + * to the dev server app + * @param {object} $0 + * @param {Express} $0.app The [Express app](https://expressjs.com/en/4x/api.html#app) used to run the dev server + * + * @example + * + * exports.onCreateDevServer = ({ app }) => { + * app.get('/hello', function (req, res) { + * res.send('hello world') + * }) + * } + */ + onCreateDevServer?( + args: CreateDevServerArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Called when a new node is created. Plugins wishing to extend or + * transform nodes created by other plugins should implement this API. + * + * See also the documentation for `createNode` + * and [`createNodeField`](https://www.gatsbyjs.org/docs/actions/#createNodeField) + * @example + * exports.onCreateNode = ({ node, actions }) => { + * const { createNode, createNodeField } = actions + * // Transform the new node here and create a new node or + * // create a new node field. + * } + */ + onCreateNode?( + args: CreateNodeArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Called when a new page is created. This extension API is useful + * for programmatically manipulating pages created by other plugins e.g. + * if you want paths without trailing slashes. + * + * See the guide [Creating and Modifying Pages](https://www.gatsbyjs.org/docs/creating-and-modifying-pages/) + * for more on this API. + */ + onCreatePage?( + args: CreatePageArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Let plugins extend/mutate the site's webpack configuration. + * @see https://www.gatsbyjs.org/docs/node-apis/#onCreateWebpackConfig + */ + onCreateWebpackConfig?( + args: CreateWebpackConfigArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** Called at the end of the bootstrap process after all other extension APIs have been called. */ + onPostBootstrap?( + args: ParentSpanPluginArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** The last extension point called after all other parts of the build process are complete. */ + onPostBuild?( + args: BuildArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** Called at the end of the bootstrap process after all other extension APIs have been called. */ + onPreBootstrap?( + args: ParentSpanPluginArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** The first extension point called during the build process. Called after the bootstrap has completed but before the build steps start. */ + onPreBuild?( + args: BuildArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** Called once Gatsby has initialized itself and is ready to bootstrap your site. */ + onPreExtractQueries?( + args: ParentSpanPluginArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** The first API called during Gatsby execution, runs as soon as plugins are loaded, before cache initialization and bootstrap preparation. */ + onPreInit?( + args: ParentSpanPluginArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Ask compile-to-js plugins to process source to JavaScript so the query + * runner can extract out GraphQL queries for running. + */ + preprocessSource?( + args: PreprocessSourceArgs, + options?: PluginOptions, + callback?: PluginCallback + ): void + + /** + * Lets plugins implementing support for other compile-to-js add to the list of "resolvable" file extensions. Gatsby supports `.js` and `.jsx` by default. + */ + resolvableExtensions?( + args: ResolvableExtensionsArgs, + options: PluginOptions, + callback: PluginCallback + ): any[] | Promise + + /** + * Called during the creation of the GraphQL schema. Allows plugins + * to add new fields to the types created from data nodes. It will be called + * separately for each type. + * + * This function should return an object in the shape of + * [GraphQLFieldConfigMap](https://graphql.org/graphql-js/type/#graphqlobjecttype) + * which will be appended to fields inferred by Gatsby from data nodes. + * + * *Note:* Import GraphQL types from `gatsby/graphql` and don't add the `graphql` + * package to your project/plugin dependencies to avoid Schema must + * contain unique named types but contains multiple types named errors. + * `gatsby/graphql` exports all builtin GraphQL types as well as the `graphQLJSON` + * type. + * + * Many transformer plugins use this to add fields that take arguments. + * + * @see https://www.gatsbyjs.org/docs/node-apis/#setFieldsOnGraphQLNodeType + */ + setFieldsOnGraphQLNodeType?( + args: SetFieldsOnGraphQLNodeTypeArgs, + options: PluginOptions + ): any + setFieldsOnGraphQLNodeType?( + args: SetFieldsOnGraphQLNodeTypeArgs, + options: PluginOptions + ): Promise + setFieldsOnGraphQLNodeType?( + args: SetFieldsOnGraphQLNodeTypeArgs, + options: PluginOptions, + callback: PluginCallback + ): void + + /** + * Extension point to tell plugins to source nodes. This API is called during + * the Gatsby bootstrap sequence. Source plugins use this hook to create nodes. + * This API is called exactly once per plugin (and once for your site's + * `gatsby-config.js` file). If you define this hook in `gatsby-node.js` it + * will be called exactly once after all of your source plugins have finished + * creating nodes. + * + * @see https://www.gatsbyjs.org/docs/node-apis/#sourceNodes + */ + sourceNodes?(args: SourceNodesArgs, options: PluginOptions): any + sourceNodes?(args: SourceNodesArgs, options: PluginOptions): Promise + sourceNodes?( + args: SourceNodesArgs, + options: PluginOptions, + callback: PluginCallback + ): void + + /** + * Add custom field resolvers to the GraphQL schema. + * + * Allows adding new fields to types by providing field configs, or adding resolver + * functions to existing fields. + * + * Things to note: + * * Overriding field types is disallowed, instead use the `createTypes` + * action. In case of types added from third-party schemas, where this is not + * possible, overriding field types is allowed. + * * New fields will not be available on `filter` and `sort` input types. Extend + * types defined with `createTypes` if you need this. + * * In field configs, types can be referenced as strings. + * * When extending a field with an existing field resolver, the original + * resolver function is available from `info.originalResolver`. + * * The `createResolvers` API is called as the last step in schema generation. + * Thus, an intermediate schema is made available on the `schema` property. + * In resolver functions themselves, it is recommended to access the final + * built schema from `info.schema`. + * * Gatsby's data layer, including all internal query capabilities, is + * exposed on [`context.nodeModel`](/docs/node-model/). The node store can be + * queried directly with `getAllNodes`, `getNodeById` and `getNodesByIds`, + * while more advanced queries can be composed with `runQuery`. Note that + * `runQuery` will call field resolvers before querying, so e.g. foreign-key + * fields will be expanded to full nodes. The other methods on `nodeModel` + * don't do this. + * * It is possible to add fields to the root `Query` type. + * * When using the first resolver argument (`source` in the example below, + * often also called `parent` or `root`), take care of the fact that field + * resolvers can be called more than once in a query, e.g. when the field is + * present both in the input filter and in the selection set. This means that + * foreign-key fields on `source` can be either resolved or not-resolved. + * + * For fuller examples, see [`using-type-definitions`](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-type-definitions). + * + * @see https://www.gatsbyjs.org/docs/node-apis/#createResolvers + */ + createResolvers?(args: CreateResolversArgs, options: PluginOptions): any + createResolvers?( + args: CreateResolversArgs, + options: PluginOptions + ): Promise + createResolvers?( + args: CreateResolversArgs, + options: PluginOptions, + callback: PluginCallback + ): void } /** @@ -133,24 +379,48 @@ export interface GatsbyNode { * @see https://www.gatsbyjs.org/docs/browser-apis/ */ export interface GatsbyBrowser { - disableCorePrefetching?(args: BrowserPluginArgs, options: PluginOptions): any; - onClientEntry?(args: BrowserPluginArgs, options: PluginOptions): any; - onInitialClientRender?(args: BrowserPluginArgs, options: PluginOptions): any; - onPostPrefetchPathname?(args: PostPrefetchPathnameArgs, options: PluginOptions): any; - onPreRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): any; - onPrefetchPathname?(args: BrowserPluginArgs, options: PluginOptions): any; - onRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): any; - onRouteUpdateDelayed?(args: BrowserPluginArgs, options: PluginOptions): any; - onServiceWorkerActive?(args: BrowserPluginArgs, options: PluginOptions): any; - onServiceWorkerInstalled?(args: BrowserPluginArgs, options: PluginOptions): any; - onServiceWorkerRedundant?(args: BrowserPluginArgs, options: PluginOptions): any; - onServiceWorkerUpdateFound?(args: BrowserPluginArgs, options: PluginOptions): any; - registerServiceWorker?(args: BrowserPluginArgs, options: PluginOptions): any; - replaceComponentRenderer?(args: ReplaceComponentRendererArgs, options: PluginOptions): any; - replaceHydrateFunction?(args: BrowserPluginArgs, options: PluginOptions): any; - shouldUpdateScroll?(args: ShouldUpdateScrollArgs, options: PluginOptions): any; - wrapPageElement?(args: WrapPageElementBrowserArgs, options: PluginOptions): any; - wrapRootElement?(args: WrapRootElementBrowserArgs, options: PluginOptions): any; + disableCorePrefetching?(args: BrowserPluginArgs, options: PluginOptions): any + onClientEntry?(args: BrowserPluginArgs, options: PluginOptions): any + onInitialClientRender?(args: BrowserPluginArgs, options: PluginOptions): any + onPostPrefetchPathname?( + args: PrefetchPathnameArgs, + options: PluginOptions + ): any + onPreRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): any + onPrefetchPathname?(args: PrefetchPathnameArgs, options: PluginOptions): any + onRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): any + onRouteUpdateDelayed?( + args: RouteUpdateDelayedArgs, + options: PluginOptions + ): any + onServiceWorkerActive?(args: ServiceWorkerArgs, options: PluginOptions): any + onServiceWorkerInstalled?( + args: ServiceWorkerArgs, + options: PluginOptions + ): any + onServiceWorkerRedundant?( + args: ServiceWorkerArgs, + options: PluginOptions + ): any + onServiceWorkerUpdateFound?( + args: ServiceWorkerArgs, + options: PluginOptions + ): any + registerServiceWorker?(args: BrowserPluginArgs, options: PluginOptions): any + replaceComponentRenderer?( + args: ReplaceComponentRendererArgs, + options: PluginOptions + ): any + replaceHydrateFunction?(args: BrowserPluginArgs, options: PluginOptions): any + shouldUpdateScroll?(args: ShouldUpdateScrollArgs, options: PluginOptions): any + wrapPageElement?( + args: WrapPageElementBrowserArgs, + options: PluginOptions + ): any + wrapRootElement?( + args: WrapRootElementBrowserArgs, + options: PluginOptions + ): any } /** @@ -159,426 +429,713 @@ export interface GatsbyBrowser { * @see https://www.gatsbyjs.org/docs/ssr-apis/ */ export interface GatsbySSR { - onPreRenderHTML?(args: PreRenderHTMLArgs, options: PluginOptions): any; - onPreRenderHTML?(args: PreRenderHTMLArgs, options: PluginOptions): Promise; - onPreRenderHTML?(args: PreRenderHTMLArgs, options: PluginOptions, callback: PluginCallback): void; - - onRenderBody?(args: RenderBodyArgs, options: PluginOptions): any; - onRenderBody?(args: RenderBodyArgs, options: PluginOptions): Promise; - onRenderBody?(args: RenderBodyArgs, options: PluginOptions, callback: PluginCallback): void; - - replaceRenderer?(args: ReplaceRendererArgs, options: PluginOptions): any; - replaceRenderer?(args: ReplaceRendererArgs, options: PluginOptions): Promise; - replaceRenderer?(args: ReplaceRendererArgs, options: PluginOptions, callback: PluginCallback): void; - - wrapPageElement?(args: WrapPageElementNodeArgs, options: PluginOptions): any; - wrapPageElement?(args: WrapPageElementNodeArgs, options: PluginOptions): Promise; - wrapPageElement?(args: WrapPageElementNodeArgs, options: PluginOptions, callback: PluginCallback): void; - - wrapRootElement?(args: WrapRootElementNodeArgs, options: PluginOptions): any; - wrapRootElement?(args: WrapRootElementNodeArgs, options: PluginOptions): Promise; - wrapRootElement?(args: WrapRootElementNodeArgs, options: PluginOptions, callback: PluginCallback): void; + /** + * Called after every page Gatsby server renders while building HTML so you can + * replace head components to be rendered in your `html.js`. This is useful if + * you need to reorder scripts or styles added by other plugins. + * @example + * // Move Typography.js styles to the top of the head section so they're loaded first. + * exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => { + * const headComponents = getHeadComponents() + * headComponents.sort((x, y) => { + * if (x.key === 'TypographyStyle') { + * return -1 + * } else if (y.key === 'TypographyStyle') { + * return 1 + * } + * return 0 + * }) + * replaceHeadComponents(headComponents) + * } + */ + onPreRenderHTML?(args: PreRenderHTMLArgs, options: PluginOptions): any + onPreRenderHTML?( + args: PreRenderHTMLArgs, + options: PluginOptions + ): Promise + onPreRenderHTML?( + args: PreRenderHTMLArgs, + options: PluginOptions, + callback: PluginCallback + ): void + + /** + * Called after every page Gatsby server renders while building HTML so you can + * set head and body components to be rendered in your `html.js`. + * + * Gatsby does a two-pass render for HTML. It loops through your pages first + * rendering only the body and then takes the result body HTML string and + * passes it as the `body` prop to your `html.js` to complete the render. + * + * It's often handy to be able to send custom components to your `html.js`. + * For example, it's a very common pattern for React.js libraries that + * support server rendering to pull out data generated during the render to + * add to your HTML. + * + * Using this API over `replaceRenderer` is preferable as + * multiple plugins can implement this API where only one plugin can take + * over server rendering. However, if your plugin requires taking over server + * rendering then that's the one to use + * @example + * const { Helmet } = require("react-helmet") + * + * exports.onRenderBody = ( + * { setHeadComponents, setHtmlAttributes, setBodyAttributes }, + * pluginOptions + * ) => { + * const helmet = Helmet.renderStatic() + * setHtmlAttributes(helmet.htmlAttributes.toComponent()) + * setBodyAttributes(helmet.bodyAttributes.toComponent()) + * setHeadComponents([ + * helmet.title.toComponent(), + * helmet.link.toComponent(), + * helmet.meta.toComponent(), + * helmet.noscript.toComponent(), + * helmet.script.toComponent(), + * helmet.style.toComponent(), + * ]) + * } + */ + onRenderBody?(args: RenderBodyArgs, options: PluginOptions): any + onRenderBody?(args: RenderBodyArgs, options: PluginOptions): Promise + onRenderBody?( + args: RenderBodyArgs, + options: PluginOptions, + callback: PluginCallback + ): void + + /** + * Replace the default server renderer. This is useful for integration with + * Redux, css-in-js libraries, etc. that need custom setups for server + * rendering. + * @example + * // From gatsby-plugin-glamor + * const { renderToString } = require("react-dom/server") + * const inline = require("glamor-inline") + * + * exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { + * const bodyHTML = renderToString(bodyComponent) + * const inlinedHTML = inline(bodyHTML) + * + * replaceBodyHTMLString(inlinedHTML) + * } + */ + replaceRenderer?(args: ReplaceRendererArgs, options: PluginOptions): any + replaceRenderer?( + args: ReplaceRendererArgs, + options: PluginOptions + ): Promise + replaceRenderer?( + args: ReplaceRendererArgs, + options: PluginOptions, + callback: PluginCallback + ): void + + /** + * Allow a plugin to wrap the page element. + * + * This is useful for setting wrapper component around pages that won't get + * unmounted on page change. For setting Provider components use `wrapRootElement`. + * + * _Note:_ [There is equivalent hook in Browser API](https://www.gatsbyjs.org/docs/browser-apis/#wrapPageElement) + * @example + * const React = require("react") + * const Layout = require("./src/components/layout") + * + * exports.wrapPageElement = ({ element, props }) => { + * // props provide same data to Layout as Page element will get + * // including location, data, etc - you don't need to pass it + * return {element} + * } + */ + wrapPageElement?(args: WrapPageElementNodeArgs, options: PluginOptions): any + wrapPageElement?( + args: WrapPageElementNodeArgs, + options: PluginOptions + ): Promise + wrapPageElement?( + args: WrapPageElementNodeArgs, + options: PluginOptions, + callback: PluginCallback + ): void + /** + * Allow a plugin to wrap the root element. + * + * This is useful to setup any Providers component that will wrap your application. + * For setting persistent UI elements around pages use `wrapPageElement`. + * + * _Note:_ [There is equivalent hook in Browser API](https://www.gatsbyjs.org/docs/browser-apis/#wrapRootElement) + * @example + * const React = require("react") + * const { Provider } = require("react-redux") + * + * const createStore = require("./src/state/createStore") + * const store = createStore() + * + * exports.wrapRootElement = ({ element }) => { + * return ( + * + * {element} + * + * ) + * } + */ + wrapRootElement?(args: WrapRootElementNodeArgs, options: PluginOptions): any + wrapRootElement?( + args: WrapRootElementNodeArgs, + options: PluginOptions + ): Promise + wrapRootElement?( + args: WrapRootElementNodeArgs, + options: PluginOptions, + callback: PluginCallback + ): void } export interface PluginOptions { - plugins: unknown[]; - path?: string; - pathCheck?: boolean; - [key: string]: unknown; + plugins: unknown[] + [key: string]: unknown } -export type PluginCallback = (err: Error | null, result?: any) => void; +export type PluginCallback = (err: Error | null, result?: any) => void export interface CreatePagesArgs extends ParentSpanPluginArgs { - graphql: Function; - traceId: string; - waitForCascadingActions: boolean; + graphql: Function + traceId: string + waitForCascadingActions: boolean } +type GatsbyStages = + | "develop" + | "develop-html" + | "build-javascript" + | "build-html" + export interface CreateBabelConfigArgs extends ParentSpanPluginArgs { - stage: string; + stage: GatsbyStages } export interface CreateDevServerArgs extends ParentSpanPluginArgs { - app: Application; + app: Application } export interface CreateNodeArgs extends ParentSpanPluginArgs { - node: Node; - traceId: string; + node: Node + traceId: string traceTags: { - nodeId: string; - nodeType: string; - }; + nodeId: string + nodeType: string + } } export interface CreatePageArgs extends ParentSpanPluginArgs { - page: Node; - traceId: string; + page: Node + traceId: string } export interface CreateWebpackConfigArgs extends ParentSpanPluginArgs { - getConfig: Function; - stage: string; - rules: WebpackRules; - loaders: WebpackLoaders; - plugins: WebpackPlugins; + getConfig: Function + stage: GatsbyStages + rules: WebpackRules + loaders: WebpackLoaders + plugins: WebpackPlugins } export interface PreprocessSourceArgs extends ParentSpanPluginArgs { - filename: string; - contents: string; + filename: string + contents: string } export interface ResolvableExtensionsArgs extends ParentSpanPluginArgs { - traceId: string; + traceId: "initial-resolvableExtensions" } export interface SetFieldsOnGraphQLNodeTypeArgs extends ParentSpanPluginArgs { type: { - name: string; - nodes: any[]; - }; - traceId: string; + name: string + nodes: any[] + } + traceId: "initial-setFieldsOnGraphQLNodeType" } export interface SourceNodesArgs extends ParentSpanPluginArgs { - traceId: string; - waitForCascadingActions: boolean; + traceId: "initial-sourceNodes" + waitForCascadingActions: boolean +} + +export interface CreateResolversArgs extends ParentSpanPluginArgs { + schema: object + createResolvers: Function + traceId: `initial-createResolvers` } export interface PreRenderHTMLArgs extends NodePluginArgs { - getHeadComponents: any[]; - replaceHeadComponents: Function; - getPreBodyComponents: any[]; - replacePreBodyComponents: Function; - getPostBodyComponents: any[]; - replacePostBodyComponents: Function; + getHeadComponents: any[] + replaceHeadComponents: Function + getPreBodyComponents: any[] + replacePreBodyComponents: Function + getPostBodyComponents: any[] + replacePostBodyComponents: Function } export interface RenderBodyArgs extends NodePluginArgs { - pathname: string; - setHeadComponents: Function; - setHtmlAttributes: Function; - setBodyAttributes: Function; - setPreBodyComponents: Function; - setPostBodyComponents: Function; - setBodyProps: Function; + pathname: string + setHeadComponents: Function + setHtmlAttributes: Function + setBodyAttributes: Function + setPreBodyComponents: Function + setPostBodyComponents: Function + setBodyProps: Function } export interface ReplaceRendererArgs extends NodePluginArgs { - replaceBodyHTMLString: Function; - setHeadComponents: Function; - setHtmlAttributes: Function; - setBodyAttributes: Function; - setPreBodyComponents: Function; - setPostBodyComponents: Function; - setBodyProps: Function; + replaceBodyHTMLString: Function + setHeadComponents: Function + setHtmlAttributes: Function + setBodyAttributes: Function + setPreBodyComponents: Function + setPostBodyComponents: Function + setBodyProps: Function } export interface WrapPageElementNodeArgs extends NodePluginArgs { - element: object; - props: object; - pathname: string; + element: object + props: object + pathname: string } export interface WrapRootElementNodeArgs extends NodePluginArgs { - element: object; + element: object } export interface ParentSpanPluginArgs extends NodePluginArgs { - parentSpan: object; + parentSpan: object } export interface NodePluginArgs { - pathPrefix: string; - boundActionCreators: Actions; - actions: Actions; - loadNodeContent: Function; - store: Store; - emitter: EventEmitter; - getNodes: Function; - getNode: Function; - getNodesByType: Function; - hasNodeChanged: Function; - reporter: Reporter; - getNodeAndSavePathDependency: Function; - cache: Cache; - createNodeId: Function; - createContentDigest: Function; - tracing: Tracing; - [key: string]: unknown; + pathPrefix: string + boundActionCreators: Actions + actions: Actions + loadNodeContent: Function + store: Store + emitter: EventEmitter + getNodes: Function + getNode: Function + getNodesByType: Function + hasNodeChanged: Function + reporter: Reporter + getNodeAndSavePathDependency: Function + cache: Cache + createNodeId: Function + createContentDigest: Function + tracing: Tracing + [key: string]: unknown +} + +interface ActionPlugin { + name: string +} + +interface DeleteNodeArgs { + node: Node +} + +interface CreateNodeFieldArgs { + node: Node + name: string + value: string + + /** + * @deprecated + */ + fieldName?: string + + /** + * @deprecated + */ + fieldValue?: string +} + +interface ActionOptions { + [key: string]: unknown +} + +export interface BuildArgs extends ParentSpanPluginArgs { + graphql: Function } export interface Actions { - deletePage: Function; - createPage: Function; - deleteNode: Function; - deleteNodes: Function; - createNode: Function; - touchNode: Function; - createNodeField: Function; - createParentChildLink: Function; - createPageDependency: Function; - deleteComponentsDependencies: Function; - replaceComponentQuery: Function; - replaceStaticQuery: Function; - setWebpackConfig: Function; - replaceWebpackConfig: Function; - setBabelOptions: Function; - setBabelPlugin: Function; - setBabelPreset: Function; - createJob: Function; - setJob: Function; - endJob: Function; - setPluginStatus: Function; - createRedirect: Function; - addThirdPartySchema: Function; + /** @see https://www.gatsbyjs.org/docs/actions/#deletePage */ + deletePage(args: { path: string; component: string }): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createPage */ + createPage( + args: { path: string; component: string; context: Record }, + plugin?: ActionPlugin, + option?: ActionOptions + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#deletePage */ + deleteNode( + options: { node: Node }, + plugin?: ActionPlugin, + option?: ActionOptions + ): void + + /** + * @deprecated + * @see https://www.gatsbyjs.org/docs/actions/#deleteNodes + */ + deleteNodes(nodes: string[], plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createNode */ + createNode(node: Node, plugin?: ActionPlugin, options?: ActionOptions): void + + /** @see https://www.gatsbyjs.org/docs/actions/#touchNode */ + touchNode(node: { nodeId: string; plugin?: ActionPlugin }): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createNodeField */ + createNodeField( + args: { + node: Node + fieldName?: string + fieldValue?: string + name?: string + value: any + }, + plugin?: ActionPlugin, + options?: ActionOptions + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createParentChildLink */ + createParentChildLink( + { parent: Node, child: Node }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setWebpackConfig */ + setWebpackConfig(config: object, plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#replaceWebpackConfig */ + replaceWebpackConfig(config: object, plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setBabelOptions */ + setBabelOptions(options: object, plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setBabelPlugin */ + setBabelPlugin( + config: { name: string; options: object }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setBabelPreset */ + setBabelPreset( + config: { name: string; options: object }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createJob */ + createJob( + job: Record & { id: string }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setJob */ + setJob( + job: Record & { id: string }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#endJob */ + endJob(job: { id: string }, plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#setPluginStatus */ + setPluginStatus(status: Record, plugin?: ActionPlugin): void + + /** @see https://www.gatsbyjs.org/docs/actions/#createRedirect */ + createRedirect( + redirect: { + fromPath: string + isPermanent: boolean + toPath: string + redirectInBrowser: boolean + force: boolean + statusCode: number + }, + plugin?: ActionPlugin + ): void + + /** @see https://www.gatsbyjs.org/docs/actions/#addThirdPartySchema */ + addThirdPartySchema( + args: { schema: object }, + plugin?: ActionPlugin, + traceId: string + ) + + /** TODO create jsdoc on gatsbyjs.org */ + createTypes( + types: string | object | Array, + plugin?: ActionPlugin, + traceId: string + ) } export interface Store { - dispatch: Function; - subscribe: Function; - getState: Function; - replaceReducer: Function; + dispatch: Function + subscribe: Function + getState: Function + replaceReducer: Function } +type logMessageType = (format: string, ...args: any[]) => void + export interface Reporter { - language: string; - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - emoji: boolean; - nonInteractive: boolean; - noProgress: boolean; - isVerbose: boolean; - isTTY: undefined; - peakMemory: number; - startTime: number; - format: Function; - isSilent: boolean; - stripIndent: Function; - setVerbose: Function; - setNoColor: Function; - panic: Function; - panicOnBuild: Function; - error: Function; - uptime: Function; - activityTimer: Function; + stripIndent: Function + format: object + setVerbose(isVerbose: boolean): void + setNoColor(isNoColor: boolean): void + panic(...args: any[]): void + panicOnBuild(...args: any[]): void + error(message: string, error: Error): void + uptime(prefix: string): void + success: logMessageType + verbose: logMessageType + info: logMessageType + warn: logMessageType + log: logMessageType + activityTimer( + name: string, + activityArgs: { parentSpan: object } + ): { + start: () => void + status(status: string): void + end: () => void + span: object + } } export interface Cache { - name: string; + name: string store: { - create: Function; - }; + create: Function + } cache: { - getAndPassUp: Function; - wrap: Function; - set: Function; - mset: Function; - get: Function; - mget: Function; - del: Function; - reset: Function; + getAndPassUp: Function + wrap: Function + set: Function + mset: Function + get: Function + mget: Function + del: Function + reset: Function } } export interface Tracing { - tracer: object; - parentSpan: object; - startSpan: Function; -} - -export interface Node { - path?: string; - id: string; - parent: string; - children: Node[]; - internal: { - type: string; - contentDigest: string; - owner: string; - description?: string; - }; - resolve?: string; - name?: string; - version?: string; - pluginOptions?: PluginOptions; - nodeAPIs?: any[]; - browserAPIs?: any[]; - ssrAPIs?: any[]; - pluginFilepath?: string; - packageJson?: PackageJson; - siteMetadata?: Record; - port?: string; - host?: string; - pathPrefix?: string; - polyfill?: boolean; - buildTime?: string; - jsonName?: string; - internalComponentName?: string; - matchPath?: unknown; - component?: string; - componentChunkName?: string; - context?: object; - pluginCreatorId?: string; - componentPath?: string; + tracer: object + parentSpan: object + startSpan: Function } export interface PackageJson { - name?: string; - description?: string; - version?: string; - main?: string; - author?: string | { - name: string; - email: string; - }; - license?: string; - dependencies?: Array>; - devDependencies?: Array>; - peerDependencies?: Array>; - optionalDependecies?: Array>; - bundledDependecies?: Array>; - keywords?: string[]; + name?: string + description?: string + version?: string + main?: string + author?: + | string + | { + name: string + email: string + } + license?: string + dependencies?: Array> + devDependencies?: Array> + peerDependencies?: Array> + optionalDependecies?: Array> + bundledDependecies?: Array> + keywords?: string[] } export interface WebpackRules { - js: Function; - mjs: Function; - eslint: Function; - yaml: Function; - fonts: Function; - images: Function; - media: Function; - miscAssets: Function; - css: Function; - cssModules: Function; - postcss: Function; - [key: string]: Function; + js: Function + mjs: Function + eslint: Function + yaml: Function + fonts: Function + images: Function + media: Function + miscAssets: Function + css: Function + cssModules: Function + postcss: Function + [key: string]: Function } export interface WebpackLoaders { - json: Function; - yaml: Function; - null: Function; - raw: Function; - style: Function; - miniCssExtract: Function; - css: Function; - postcss: Function; - file: Function; - url: Function; - js: Function; - eslint: Function; - imports: Function; - exports: Function; - [key: string]: Function; + json: Function + yaml: Function + null: Function + raw: Function + style: Function + miniCssExtract: Function + css: Function + postcss: Function + file: Function + url: Function + js: Function + eslint: Function + imports: Function + exports: Function + [key: string]: Function } export interface WebpackPlugins { - normalModuleReplacement: Function; - contextReplacement: Function; - ignore: Function; - watchIgnore: Function; - banner: Function; - prefetch: Function; - automaticPrefetch: Function; - define: Function; - provide: Function; - hotModuleReplacement: Function; - sourceMapDevTool: Function; - evalSourceMapDevTool: Function; - evalDevToolModule: Function; - cache: Function; - extendedAPI: Function; - externals: Function; - jsonpTemplate: Function; - libraryTemplate: Function; - loaderTarget: Function; - memoryOutputFile: Function; - progress: Function; - setVarMainTemplate: Function; - umdMainTemplate: Function; - noErrors: Function; - noEmitOnErrors: Function; - newWatching: Function; - environment: Function; - dll: Function; - dllReference: Function; - loaderOptions: Function; - namedModules: Function; - namedChunks: Function; - hashedModuleIds: Function; - moduleFilenameH: Function; - aggressiveMerging: Function; - aggressiveSplitting: Function; - splitChunks: Function; - chunkModuleIdRange: Function; - dedupe: Function; - limitChunkCount: Function; - minChunkSize: Function; - occurrenceOrder: Function; - moduleConcatenation: Function; - minifyJs: Function; - minifyCss: Function; - extractText: Function; - moment: Function; - [key: string]: Function; -} - -export interface PostPrefetchPathnameArgs extends BrowserPluginArgs { - pathname: string; + normalModuleReplacement: Function + contextReplacement: Function + ignore: Function + watchIgnore: Function + banner: Function + prefetch: Function + automaticPrefetch: Function + define: Function + provide: Function + hotModuleReplacement: Function + sourceMapDevTool: Function + evalSourceMapDevTool: Function + evalDevToolModule: Function + cache: Function + extendedAPI: Function + externals: Function + jsonpTemplate: Function + libraryTemplate: Function + loaderTarget: Function + memoryOutputFile: Function + progress: Function + setVarMainTemplate: Function + umdMainTemplate: Function + noErrors: Function + noEmitOnErrors: Function + newWatching: Function + environment: Function + dll: Function + dllReference: Function + loaderOptions: Function + namedModules: Function + namedChunks: Function + hashedModuleIds: Function + moduleFilenameH: Function + aggressiveMerging: Function + aggressiveSplitting: Function + splitChunks: Function + chunkModuleIdRange: Function + dedupe: Function + limitChunkCount: Function + minChunkSize: Function + occurrenceOrder: Function + moduleConcatenation: Function + minifyJs: Function + minifyCss: Function + extractText: Function + moment: Function + [key: string]: Function +} + +export interface PrefetchPathnameArgs extends BrowserPluginArgs { + pathname: string } export interface RouteUpdateArgs extends BrowserPluginArgs { - location: Location; + location: Location } export interface ReplaceComponentRendererArgs extends BrowserPluginArgs { props: { - path: string; - "*": string; - uri: string; - location: object; - navigate: Function; - children: undefined; - pageResources: object; - data: object; - pageContext: object; - }; - loader: object; + path: string + "*": string + uri: string + location: object + navigate: Function + children: undefined + pageResources: object + data: object + pageContext: object + } + loader: object } export interface ShouldUpdateScrollArgs extends BrowserPluginArgs { - prevRouterProps: null; - pathname: string; + prevRouterProps?: { + location: Location + } + pathname: string routerProps: { - location: Location; - }; - getSavedScrollPosition: Function; + location: Location + } + getSavedScrollPosition: Function } export interface WrapPageElementBrowserArgs extends BrowserPluginArgs { - element: object; - props: object; + element: object + props: object } export interface WrapRootElementBrowserArgs extends BrowserPluginArgs { - element: object; + element: object + pathname: string } export interface BrowserPluginArgs { - getResourcesForPathnameSync: Function; - getResourcesForPathname: Function; - getResourceURLsForPathname: Function; - [key: string]: unknown; + getResourcesForPathnameSync: Function + getResourcesForPathname: Function + getResourceURLsForPathname: Function + [key: string]: unknown } -export const parsePath: (path: string) => WindowLocation -export interface PageRendererProps { - location: WindowLocation +export interface RouteUpdateDelayedArgs extends BrowserPluginArgs { + location: Location } -export class PageRenderer extends React.Component {} +export interface ServiceWorkerArgs extends BrowserPluginArgs { + serviceWorker: ServiceWorkerRegistration +} + +export interface Node { + path?: string + id: string + parent: string + children: Node[] + fields?: Record + internal: { + type: string + mediaType: string + content: string + contentDigest: string + owner: string + description?: string + } + resolve?: string + name?: string + version?: string + pluginOptions?: PluginOptions + nodeAPIs?: any[] + browserAPIs?: any[] + ssrAPIs?: any[] + pluginFilepath?: string + packageJson?: PackageJson + siteMetadata?: Record + port?: string + host?: string + pathPrefix?: string + polyfill?: boolean + buildTime?: string + jsonName?: string + internalComponentName?: string + matchPath?: unknown + component?: string + componentChunkName?: string + context?: Record + pluginCreatorId?: string + componentPath?: string + [key: string]: unknown +}