gatsby 5.2.0-next.1 → 5.2.0

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.
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _sanitizeNode = _interopRequireDefault(require("../../utils/sanitize-node"));
3
+ var _sanitizeNode = require("../../utils/sanitize-node");
6
4
 
7
5
  var _joi = require("../../joi-schemas/joi");
8
6
 
@@ -502,7 +500,7 @@ ${reservedFields.map(f => ` * "${f}"`).join(`\n`)}
502
500
  } // Sanitize page object so we don't attempt to serialize user-provided objects that are not serializable later
503
501
 
504
502
 
505
- const sanitizedPayload = (0, _sanitizeNode.default)(internalPage);
503
+ const sanitizedPayload = (0, _sanitizeNode.sanitizeNode)(internalPage);
506
504
  const actions = [{ ...actionOptions,
507
505
  type: `CREATE_PAGE`,
508
506
  contextModified,
@@ -755,7 +753,7 @@ const createNode = (node, plugin, actionOptions = {}) => {
755
753
  `);
756
754
  }
757
755
 
758
- node = (0, _sanitizeNode.default)(node);
756
+ node = (0, _sanitizeNode.sanitizeNode)(node);
759
757
  const oldNode = getNode(node.id); // Ensure the plugin isn't creating a node type owned by another
760
758
  // plugin. Type "ownership" is first come first served.
761
759
 
@@ -949,7 +947,7 @@ actions.createNodeField = ({
949
947
 
950
948
  node.fields[name] = value;
951
949
  node.internal.fieldOwners[schemaFieldName] = plugin.name;
952
- node = (0, _sanitizeNode.default)(node);
950
+ node = (0, _sanitizeNode.sanitizeNode)(node);
953
951
  return { ...actionOptions,
954
952
  type: `ADD_FIELD_TO_NODE`,
955
953
  plugin,
@@ -1 +1 @@
1
- {"version":3,"file":"public.js","names":["reporter","require","chalk","_","stripIndent","report","platform","path","trueCasePathSync","url","slash","createContentDigest","splitComponentPath","hasNodeChanged","getNode","getDataStore","store","validateComponent","generateComponentChunkName","getCommonDir","truncatePath","tooLongSegmentsInPath","applyTrailingSlashOption","apiRunnerNode","trackCli","getNonGatsbyCodeFrame","getPageMode","normalizePath","default","isNotTestEnv","process","env","NODE_ENV","isTestEnv","shadowCreatePagePath","memoize","createInternalJob","actions","isWindows","ensureWindowsDriveIsUppercase","filePath","segments","split","filter","s","length","shift","toUpperCase","join","findChildren","initialChildren","children","queue","traversedNodes","Set","currentChild","pop","has","id","add","newChildren","isArray","push","deletePage","page","type","payload","hasWarnedForPageComponentInvalidContext","hasWarnedForPageComponentInvalidCasing","hasErroredBecauseOfNodeValidation","pageComponentCache","Map","reservedFields","createPage","plugin","actionOptions","name","message","panic","context","pluginName","pageObject","invalidFields","field","error","map","f","JSON","stringify","some","component","warn","input","pageComponentPath","config","program","getState","trailingSlash","directory","panicOnBuild","errorIdMap","noPath","notAbsolute","doesNotExist","empty","noDefaultExport","get","originalPageComponent","splitPath","trueComponentPath","e","commonDir","relativePath","win32","relative","markers","letter","index","set","internalComponentName","invalidPathSegments","truncatedPath","internalPage","matchPath","componentPath","componentChunkName","isCreatedByStatefulCreatePages","traceId","updatedAt","Date","now","slices","pluginCreator___NODE","pluginCreatorId","defer","mode","ownerNodeId","oldPage","pages","contextModified","isEqual","componentModified","slicesModified","alternateSlashPath","endsWith","slice","bold","yellow","node","internal","contentDigest","oldNode","deleteActions","updateNodeAction","createDeleteAction","counter","getNextNodeCounter","sanitizedPayload","sanitizeNode","deleteNodeDeprecationWarningDisplayedMessages","deleteNode","internalNode","typeOwners","Error","deleteAction","deleteDescendantsActions","lastNodeCounter","status","LAST_NODE_COUNTER","Number","MAX_SAFE_INTEGER","createNode","isObject","console","log","red","array","parent","owner","trackParams","version","debounce","result","nodeSchema","validate","errorObj","validationErrorMessage","possiblyCodeFrame","codeFrame","fileName","location","start","line","column","fields","parentSpan","setTag","args","dispatch","createNodeAction","Array","find","action","Promise","resolve","undefined","maybePromise","wrapNode","traceTags","nodeId","nodeType","then","res","ready","touchNodeDeprecationWarningDisplayedMessages","touchNode","createNodeField","value","fieldOwners","schemaFieldName","includes","fieldOwner","addedField","createParentChildLink","child","setWebpackConfig","fs","fallback","replaceWebpackConfig","setBabelOptions","options","exit","setBabelPlugin","setBabelPreset","createJob","job","msg","reportOnce","createJobV2","internalJob","maybeWorkerPromise","maybeSendJobToMainProcess","createJobV2FromInternalJob","addGatsbyImageSourceUrl","sourceUrl","setJob","endJob","setPluginStatus","maybeAddPathPrefix","pathPrefix","parsed","parse","isRelativeProtocol","startsWith","protocol","createRedirect","fromPath","isPermanent","redirectInBrowser","toPath","ignoreCase","rest","prefixPaths","createPageDependency","connection","createServerVisitedPage","chunkName","visitedPages","unstable_createNodeManifest","manifestId","updatedAtUTC","setRequestHeaders","domain","headers","headersIsObject","noHeaders","noDomain","baseDomain","hostname","module","exports"],"sources":["../../../src/redux/actions/public.js"],"sourcesContent":["// @flow\nconst reporter = require(`gatsby-cli/lib/reporter`)\nconst chalk = require(`chalk`)\nconst _ = require(`lodash`)\nconst { stripIndent } = require(`common-tags`)\nconst report = require(`gatsby-cli/lib/reporter`)\nconst { platform } = require(`os`)\nconst path = require(`path`)\nconst { trueCasePathSync } = require(`true-case-path`)\nconst url = require(`url`)\nconst { slash } = require(`gatsby-core-utils/path`)\nconst {\n createContentDigest,\n} = require(`gatsby-core-utils/create-content-digest`)\nconst { splitComponentPath } = require(`gatsby-core-utils/parse-component-path`)\nconst { hasNodeChanged } = require(`../../utils/nodes`)\nconst { getNode, getDataStore } = require(`../../datastore`)\nimport sanitizeNode from \"../../utils/sanitize-node\"\nconst { store } = require(`../index`)\nconst { validateComponent } = require(`../../utils/validate-component`)\nimport { nodeSchema } from \"../../joi-schemas/joi\"\nconst { generateComponentChunkName } = require(`../../utils/js-chunk-names`)\nconst {\n getCommonDir,\n truncatePath,\n tooLongSegmentsInPath,\n} = require(`../../utils/path`)\nconst { applyTrailingSlashOption } = require(`gatsby-page-utils`)\nconst apiRunnerNode = require(`../../utils/api-runner-node`)\nconst { trackCli } = require(`gatsby-telemetry`)\nconst { getNonGatsbyCodeFrame } = require(`../../utils/stack-trace-utils`)\nconst { getPageMode } = require(`../../utils/page-mode`)\nconst normalizePath = require(`../../utils/normalize-path`).default\nimport { createJobV2FromInternalJob } from \"./internal\"\nimport { maybeSendJobToMainProcess } from \"../../utils/jobs/worker-messaging\"\nimport { reportOnce } from \"../../utils/report-once\"\nimport { wrapNode } from \"../../utils/detect-node-mutations\"\n\nconst isNotTestEnv = process.env.NODE_ENV !== `test`\nconst isTestEnv = process.env.NODE_ENV === `test`\n\n// Memoize function used to pick shadowed page components to avoid expensive I/O.\n// Ideally, we should invalidate memoized values if there are any FS operations\n// on files that are in shadowing chain, but webpack currently doesn't handle\n// shadowing changes during develop session, so no invalidation is not a deal breaker.\nconst shadowCreatePagePath = _.memoize(\n require(`../../internal-plugins/webpack-theme-component-shadowing/create-page`)\n)\nconst { createInternalJob } = require(`../../utils/jobs/manager`)\n\nconst actions = {}\nconst isWindows = platform() === `win32`\n\nconst ensureWindowsDriveIsUppercase = filePath => {\n const segments = filePath.split(`:`).filter(s => s !== ``)\n return segments.length > 0\n ? segments.shift().toUpperCase() + `:` + segments.join(`:`)\n : filePath\n}\n\nconst findChildren = initialChildren => {\n const children = [...initialChildren]\n const queue = [...initialChildren]\n const traversedNodes = new Set()\n\n while (queue.length > 0) {\n const currentChild = getNode(queue.pop())\n if (!currentChild || traversedNodes.has(currentChild.id)) {\n continue\n }\n traversedNodes.add(currentChild.id)\n const newChildren = currentChild.children\n if (_.isArray(newChildren) && newChildren.length > 0) {\n children.push(...newChildren)\n queue.push(...newChildren)\n }\n }\n return children\n}\n\nimport type { Plugin } from \"./types\"\n\ntype Job = {\n id: string,\n}\n\ntype JobV2 = {\n name: string,\n inputPaths: string[],\n outputDir: string,\n args: Object,\n}\n\nexport interface IPageInput {\n path: string;\n component: string;\n context?: Object;\n ownerNodeId?: string;\n defer?: boolean;\n slices: Record<string, string>;\n}\n\ntype PageMode = \"SSG\" | \"DSG\" | \"SSR\"\n\ntype Page = {\n path: string,\n matchPath: ?string,\n component: string,\n context: Object,\n internalComponentName: string,\n componentChunkName: string,\n updatedAt: number,\n ownerNodeId?: string,\n mode: PageMode,\n slices: Record<string, string>,\n}\n\ntype ActionOptions = {\n traceId: ?string,\n parentSpan: ?Object,\n followsSpan: ?Object,\n}\n\ntype PageData = {\n id: string,\n resultHash: string,\n}\n\ntype PageDataRemove = {\n id: string,\n}\n\n/**\n * Delete a page\n * @param {Object} page a page object\n * @param {string} page.path The path of the page\n * @param {string} page.component The absolute path to the page component\n * @example\n * deletePage(page)\n */\nactions.deletePage = (page: IPageInput) => {\n return {\n type: `DELETE_PAGE`,\n payload: page,\n }\n}\n\nconst hasWarnedForPageComponentInvalidContext = new Set()\nconst hasWarnedForPageComponentInvalidCasing = new Set()\nconst hasErroredBecauseOfNodeValidation = new Set()\nconst pageComponentCache = new Map()\nconst reservedFields = [\n `path`,\n `matchPath`,\n `component`,\n `componentChunkName`,\n `pluginCreator___NODE`,\n `pluginCreatorId`,\n]\n/**\n * Create a page. See [the guide on creating and modifying pages](/docs/creating-and-modifying-pages/)\n * for detailed documentation about creating pages.\n * @param {Object} page a page object\n * @param {string} page.path Any valid URL. Must start with a forward slash. Unicode characters should be passed directly and not encoded (eg. `á` not `%C3%A1`).\n * @param {string} page.matchPath Path that Reach Router uses to match the page on the client side.\n * Also see docs on [matchPath](/docs/gatsby-internals-terminology/#matchpath)\n * @param {string} page.ownerNodeId The id of the node that owns this page. This is used for routing users to previews via the unstable_createNodeManifest public action. Since multiple nodes can be queried on a single page, this allows the user to tell us which node is the main node for the page. Note that the ownerNodeId must be for a node which is queried on this page via a GraphQL query.\n * @param {string} page.component The absolute path to the component for this page\n * @param {Object} page.context Context data for this page. Passed as props\n * to the component `this.props.pageContext` as well as to the graphql query\n * as graphql arguments.\n * @param {Object} page.slices A mapping of alias-of-id for Slices rendered on this page. See the technical docs for the [Gatsby Slice API](/docs/reference/built-in-components/gatsby-slice).\n * @param {boolean} page.defer When set to `true`, Gatsby will exclude the page from the build step and instead generate it during the first HTTP request. Default value is `false`. Also see docs on [Deferred Static Generation](/docs/reference/rendering-options/deferred-static-generation/).\n * @example\n * createPage({\n * path: `/my-sweet-new-page/`,\n * component: path.resolve(`./src/templates/my-sweet-new-page.js`),\n * ownerNodeId: `123456`,\n * // The context is passed as props to the component as well\n * // as into the component's GraphQL query.\n * context: {\n * id: `123456`,\n * },\n * })\n */\nactions.createPage = (\n page: IPageInput,\n plugin?: Plugin,\n actionOptions?: ActionOptions\n) => {\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!page.path) {\n const message = `${name} must set the page path when creating a page`\n // Don't log out when testing\n if (isNotTestEnv) {\n report.panic({\n id: `11323`,\n context: {\n pluginName: name,\n pageObject: page,\n message,\n },\n })\n } else {\n return message\n }\n }\n\n // Validate that the context object doesn't overlap with any core page fields\n // as this will cause trouble when running graphql queries.\n if (page.context && typeof page.context === `object`) {\n const invalidFields = reservedFields.filter(field => field in page.context)\n\n if (invalidFields.length > 0) {\n const error = `${\n invalidFields.length === 1\n ? `${name} used a reserved field name in the context object when creating a page:`\n : `${name} used reserved field names in the context object when creating a page:`\n }\n\n${invalidFields.map(f => ` * \"${f}\"`).join(`\\n`)}\n\n${JSON.stringify(page, null, 4)}\n\nData in \"context\" is passed to GraphQL as potential arguments when running the\npage query.\n\nWhen arguments for GraphQL are constructed, the context object is combined with\nthe page object so *both* page object and context data are available as\narguments. So you don't need to add the page \"path\" to the context as it's\nalready available in GraphQL. If a context field duplicates a field already\nused by the page object, this can break functionality within Gatsby so must be\navoided.\n\nPlease choose another name for the conflicting fields.\n\nThe following fields are used by the page object and should be avoided.\n\n${reservedFields.map(f => ` * \"${f}\"`).join(`\\n`)}\n\n `\n if (isTestEnv) {\n return error\n // Only error if the context version is different than the page\n // version. People in v1 often thought that they needed to also pass\n // the path to context for it to be available in GraphQL\n } else if (invalidFields.some(f => page.context[f] !== page[f])) {\n report.panic({\n id: `11324`,\n context: {\n message: error,\n },\n })\n } else {\n if (!hasWarnedForPageComponentInvalidContext.has(page.component)) {\n report.warn(error)\n hasWarnedForPageComponentInvalidContext.add(page.component)\n }\n }\n }\n }\n\n // Check if a component is set.\n if (!page.component) {\n if (isNotTestEnv) {\n report.panic({\n id: `11322`,\n context: {\n input: page,\n pluginName: name,\n },\n })\n } else {\n // For test\n return `A component must be set when creating a page`\n }\n }\n\n const pageComponentPath = shadowCreatePagePath(page.component)\n if (pageComponentPath) {\n page.component = pageComponentPath\n }\n\n const { config, program } = store.getState()\n const { trailingSlash } = config\n const { directory } = program\n\n const { error, panicOnBuild } = validateComponent({\n input: page,\n pluginName: name,\n errorIdMap: {\n noPath: `11322`,\n notAbsolute: `11326`,\n doesNotExist: `11325`,\n empty: `11327`,\n noDefaultExport: `11328`,\n },\n })\n\n if (error) {\n if (isNotTestEnv) {\n if (panicOnBuild) {\n report.panicOnBuild(error)\n } else {\n report.panic(error)\n }\n }\n return `${name} must set the absolute path to the page component when creating a page`\n }\n\n // check if we've processed this component path\n // before, before running the expensive \"trueCasePath\"\n // operation\n //\n // Skip during testing as the paths don't exist on disk.\n if (isNotTestEnv) {\n if (pageComponentCache.has(page.component)) {\n page.component = pageComponentCache.get(page.component)\n } else {\n const originalPageComponent = page.component\n const splitPath = splitComponentPath(page.component)\n\n // normalize component path\n page.component = slash(splitPath[0])\n // check if path uses correct casing - incorrect casing will\n // cause issues in query compiler and inconsistencies when\n // developing on Mac or Windows and trying to deploy from\n // linux CI/CD pipeline\n let trueComponentPath\n try {\n // most systems\n trueComponentPath = slash(trueCasePathSync(page.component))\n } catch (e) {\n // systems where user doesn't have access to /\n const commonDir = getCommonDir(directory, page.component)\n\n // using `path.win32` to force case insensitive relative path\n const relativePath = slash(\n path.win32.relative(commonDir, page.component)\n )\n\n trueComponentPath = slash(trueCasePathSync(relativePath, commonDir))\n }\n\n if (isWindows) {\n page.component = ensureWindowsDriveIsUppercase(page.component)\n }\n\n if (trueComponentPath !== page.component) {\n if (!hasWarnedForPageComponentInvalidCasing.has(page.component)) {\n const markers = page.component\n .split(``)\n .map((letter, index) => {\n if (letter !== trueComponentPath[index]) {\n return `^`\n }\n return ` `\n })\n .join(``)\n\n report.warn(\n stripIndent`\n ${name} created a page with a component path that doesn't match the casing of the actual file. This may work locally, but will break on systems which are case-sensitive, e.g. most CI/CD pipelines.\n\n page.component: \"${page.component}\"\n path in filesystem: \"${trueComponentPath}\"\n ${markers}\n `\n )\n hasWarnedForPageComponentInvalidCasing.add(page.component)\n }\n\n page.component = trueComponentPath\n }\n\n if (splitPath.length > 1) {\n page.component = `${page.component}?__contentFilePath=${splitPath[1]}`\n }\n\n pageComponentCache.set(originalPageComponent, page.component)\n }\n }\n\n let internalComponentName\n if (page.path === `/`) {\n internalComponentName = `ComponentIndex`\n } else {\n internalComponentName = `Component${page.path}`\n }\n\n const invalidPathSegments = tooLongSegmentsInPath(page.path)\n\n if (invalidPathSegments.length > 0) {\n const truncatedPath = truncatePath(page.path)\n report.warn(\n report.stripIndent(`\n The path to the following page is longer than the supported limit on most\n operating systems and will cause an ENAMETOOLONG error. The path has been\n truncated to prevent this.\n\n Original Path: ${page.path}\n\n Truncated Path: ${truncatedPath}\n `)\n )\n page.path = truncatedPath\n }\n\n page.path = applyTrailingSlashOption(page.path, trailingSlash)\n\n const internalPage: Page = {\n internalComponentName,\n path: page.path,\n matchPath: page.matchPath,\n component: normalizePath(page.component),\n componentPath: normalizePath(page.component),\n componentChunkName: generateComponentChunkName(page.component),\n isCreatedByStatefulCreatePages:\n actionOptions?.traceId === `initial-createPagesStatefully`,\n // Ensure the page has a context object\n context: page.context || {},\n updatedAt: Date.now(),\n slices: page?.slices || {},\n\n // Link page to its plugin.\n pluginCreator___NODE: plugin.id ?? ``,\n pluginCreatorId: plugin.id ?? ``,\n }\n\n if (page.defer) {\n internalPage.defer = true\n }\n // Note: mode is updated in the end of the build after we get access to all page components,\n // see materializePageMode in utils/page-mode.ts\n internalPage.mode = getPageMode(internalPage)\n\n if (page.ownerNodeId) {\n internalPage.ownerNodeId = page.ownerNodeId\n }\n\n // If the path doesn't have an initial forward slash, add it.\n if (internalPage.path[0] !== `/`) {\n internalPage.path = `/${internalPage.path}`\n }\n\n const oldPage: Page = store.getState().pages.get(internalPage.path)\n const contextModified =\n !!oldPage && !_.isEqual(oldPage.context, internalPage.context)\n const componentModified =\n !!oldPage && !_.isEqual(oldPage.component, internalPage.component)\n const slicesModified =\n !!oldPage && !_.isEqual(oldPage.slices, internalPage.slices)\n\n const alternateSlashPath = page.path.endsWith(`/`)\n ? page.path.slice(0, -1)\n : page.path + `/`\n\n if (store.getState().pages.has(alternateSlashPath)) {\n report.warn(\n chalk.bold.yellow(`Non-deterministic routing danger: `) +\n `Attempting to create page: \"${page.path}\", but page \"${alternateSlashPath}\" already exists\\n` +\n chalk.bold.yellow(\n `This could lead to non-deterministic routing behavior`\n )\n )\n }\n\n // just so it's easier to c&p from createPage action creator for now - ideally it's DRYed\n const { updatedAt, ...node } = internalPage\n node.children = []\n node.internal = {\n type: `SitePage`,\n contentDigest: createContentDigest(node),\n }\n node.id = `SitePage ${internalPage.path}`\n const oldNode = getNode(node.id)\n\n let deleteActions\n let updateNodeAction\n if (oldNode && !hasNodeChanged(node.id, node.internal.contentDigest)) {\n updateNodeAction = {\n ...actionOptions,\n plugin,\n type: `TOUCH_NODE`,\n payload: node.id,\n }\n } else {\n // Remove any previously created descendant nodes as they're all due\n // to be recreated.\n if (oldNode) {\n const createDeleteAction = node => {\n return {\n ...actionOptions,\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n deleteActions = findChildren(oldNode.children)\n .map(getNode)\n .map(createDeleteAction)\n }\n\n node.internal.counter = getNextNodeCounter()\n\n updateNodeAction = {\n ...actionOptions,\n type: `CREATE_NODE`,\n plugin,\n oldNode,\n payload: node,\n }\n }\n\n // Sanitize page object so we don't attempt to serialize user-provided objects that are not serializable later\n const sanitizedPayload = sanitizeNode(internalPage)\n\n const actions = [\n {\n ...actionOptions,\n type: `CREATE_PAGE`,\n contextModified,\n componentModified,\n slicesModified,\n plugin,\n payload: sanitizedPayload,\n },\n ]\n\n if (deleteActions && deleteActions.length) {\n actions.push(...deleteActions)\n }\n\n actions.push(updateNodeAction)\n\n return actions\n}\n\nconst deleteNodeDeprecationWarningDisplayedMessages = new Set()\n\n/**\n * Delete a node\n * @param {object} node A node object. See the \"createNode\" action for more information about the node object details.\n * @example\n * deleteNode(node)\n */\nactions.deleteNode = (node: any, plugin?: Plugin) => {\n const id = node && node.id\n\n // Always get node from the store, as the node we get as an arg\n // might already have been deleted.\n const internalNode = getNode(id)\n if (plugin) {\n const pluginName = plugin.name\n\n if (\n internalNode &&\n typeOwners[internalNode.internal.type] &&\n typeOwners[internalNode.internal.type] !== pluginName\n )\n throw new Error(stripIndent`\n The plugin \"${pluginName}\" deleted a node of a type owned by another plugin.\n\n The node type \"${internalNode.internal.type}\" is owned by \"${\n typeOwners[internalNode.internal.type]\n }\".\n\n The node object passed to \"deleteNode\":\n\n ${JSON.stringify(internalNode, null, 4)}\n\n The plugin deleting the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `)\n }\n\n const createDeleteAction = node => {\n return {\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n\n const deleteAction = createDeleteAction(internalNode)\n\n // It's possible the file node was never created as sometimes tools will\n // write and then immediately delete temporary files to the file system.\n const deleteDescendantsActions =\n internalNode &&\n findChildren(internalNode.children).map(getNode).map(createDeleteAction)\n\n if (deleteDescendantsActions && deleteDescendantsActions.length) {\n return [...deleteDescendantsActions, deleteAction]\n } else {\n return deleteAction\n }\n}\n\n// We add a counter to node.internal for fast comparisons/intersections\n// of various node slices. The counter must increase even across builds.\nfunction getNextNodeCounter() {\n const lastNodeCounter = store.getState().status.LAST_NODE_COUNTER ?? 0\n if (lastNodeCounter >= Number.MAX_SAFE_INTEGER) {\n throw new Error(\n `Could not create more nodes. Maximum node count is reached: ${lastNodeCounter}`\n )\n }\n return lastNodeCounter + 1\n}\n\nconst typeOwners = {}\n\n// memberof notation is added so this code can be referenced instead of the wrapper.\n/**\n * Create a new node.\n * @memberof actions\n * @param {Object} node a node object\n * @param {string} node.id The node's ID. Must be globally unique.\n * @param {string} node.parent The ID of the parent's node. If the node is\n * derived from another node, set that node as the parent. Otherwise it can\n * just be `null`.\n * @param {Array} node.children An array of children node IDs. If you're\n * creating the children nodes while creating the parent node, add the\n * children node IDs here directly. If you're adding a child node to a\n * parent node created by a plugin, you can't mutate this value directly\n * to add your node id, instead use the action creator `createParentChildLink`.\n * @param {Object} node.internal node fields that aren't generally\n * interesting to consumers of node data but are very useful for plugin writers\n * and Gatsby core. Only fields described below are allowed in `internal` object.\n * Using any type of custom fields will result in validation errors.\n * @param {string} node.internal.mediaType An optional field to indicate to\n * transformer plugins that your node has raw content they can transform.\n * Use either an official media type (we use mime-db as our source\n * (https://www.npmjs.com/package/mime-db) or a made-up one if your data\n * doesn't fit in any existing bucket. Transformer plugins use node media types\n * for deciding if they should transform a node into a new one. E.g.\n * markdown transformers look for media types of\n * `text/markdown`.\n * @param {string} node.internal.type An arbitrary globally unique type\n * chosen by the plugin creating the node. Should be descriptive of the\n * node as the type is used in forming GraphQL types so users will query\n * for nodes based on the type chosen here. Nodes of a given type can\n * only be created by one plugin.\n * @param {string} node.internal.content An optional field. This is rarely\n * used. It is used when a source plugin sources data it doesn't know how\n * to transform e.g. a markdown string pulled from an API. The source plugin\n * can defer the transformation to a specialized transformer plugin like\n * gatsby-transformer-remark. This `content` field holds the raw content\n * (so for the markdown case, the markdown string).\n *\n * Data that's already structured should be added to the top-level of the node\n * object and _not_ added here. You should not `JSON.stringify` your node's\n * data here.\n *\n * If the content is very large and can be lazy-loaded, e.g. a file on disk,\n * you can define a `loadNodeContent` function for this node and the node\n * content will be lazy loaded when it's needed.\n * @param {string} node.internal.contentDigest the digest for the content\n * of this node. Helps Gatsby avoid doing extra work on data that hasn't\n * changed.\n * @param {string} node.internal.description An optional field. Human\n * readable description of what this node represent / its source. It will\n * be displayed when type conflicts are found, making it easier to find\n * and correct type conflicts.\n * @returns {Promise} The returned Promise resolves when all cascading\n * `onCreateNode` API calls triggered by `createNode` have finished.\n * @example\n * createNode({\n * // Data for the node.\n * field1: `a string`,\n * field2: 10,\n * field3: true,\n * ...arbitraryOtherData,\n *\n * // Required fields.\n * id: `a-node-id`,\n * parent: `the-id-of-the-parent-node`, // or null if it's a source node without a parent\n * children: [],\n * internal: {\n * type: `CoolServiceMarkdownField`,\n * contentDigest: crypto\n * .createHash(`md5`)\n * .update(JSON.stringify(fieldData))\n * .digest(`hex`),\n * mediaType: `text/markdown`, // optional\n * content: JSON.stringify(fieldData), // optional\n * description: `Cool Service: \"Title of entry\"`, // optional\n * }\n * })\n */\nconst createNode = (\n node: any,\n plugin?: Plugin,\n actionOptions?: ActionOptions = {}\n) => {\n if (!_.isObject(node)) {\n return console.log(\n chalk.bold.red(\n `The node passed to the \"createNode\" action creator must be an object`\n )\n )\n }\n\n // Ensure the new node has an internals object.\n if (!node.internal) {\n node.internal = {}\n }\n\n // Ensure the new node has a children array.\n if (!node.array && !_.isArray(node.children)) {\n node.children = []\n }\n\n // Ensure the new node has a parent field\n if (!node.parent) {\n node.parent = null\n }\n\n // Tell user not to set the owner name themself.\n if (node.internal.owner) {\n report.error(JSON.stringify(node, null, 4))\n report.panic(\n chalk.bold.red(\n `The node internal.owner field is set automatically by Gatsby and not by plugins`\n )\n )\n }\n\n const trackParams = {}\n // Add the plugin name to the internal object.\n if (plugin) {\n node.internal.owner = plugin.name\n trackParams[`pluginName`] = `${plugin.name}@${plugin.version}`\n }\n\n trackCli(`CREATE_NODE`, trackParams, { debounce: true })\n\n const result = nodeSchema.validate(node)\n if (result.error) {\n if (!hasErroredBecauseOfNodeValidation.has(result.error.message)) {\n const errorObj = {\n id: `11467`,\n context: {\n validationErrorMessage: result.error.message,\n node,\n },\n }\n\n const possiblyCodeFrame = getNonGatsbyCodeFrame()\n if (possiblyCodeFrame) {\n errorObj.context.codeFrame = possiblyCodeFrame.codeFrame\n errorObj.filePath = possiblyCodeFrame.fileName\n errorObj.location = {\n start: {\n line: possiblyCodeFrame.line,\n column: possiblyCodeFrame.column,\n },\n }\n }\n\n report.error(errorObj)\n hasErroredBecauseOfNodeValidation.add(result.error.message)\n }\n\n return { type: `VALIDATION_ERROR`, error: true }\n }\n\n // Ensure node isn't directly setting fields.\n if (node.fields) {\n throw new Error(\n stripIndent`\n Plugins creating nodes can not set data on the reserved field \"fields\"\n as this is reserved for plugins which wish to extend your nodes.\n\n If your plugin didn't add \"fields\" you're probably seeing this\n error because you're reusing an old node object.\n\n Node:\n\n ${JSON.stringify(node, null, 4)}\n\n Plugin that created the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `\n )\n }\n\n node = sanitizeNode(node)\n\n const oldNode = getNode(node.id)\n\n // Ensure the plugin isn't creating a node type owned by another\n // plugin. Type \"ownership\" is first come first served.\n if (plugin) {\n const pluginName = plugin.name\n\n if (!typeOwners[node.internal.type])\n typeOwners[node.internal.type] = pluginName\n else if (typeOwners[node.internal.type] !== pluginName)\n throw new Error(stripIndent`\n The plugin \"${pluginName}\" created a node of a type owned by another plugin.\n\n The node type \"${node.internal.type}\" is owned by \"${\n typeOwners[node.internal.type]\n }\".\n\n If you copy and pasted code from elsewhere, you'll need to pick a new type name\n for your new node(s).\n\n The node object passed to \"createNode\":\n\n ${JSON.stringify(node, null, 4)}\n\n The plugin creating the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `)\n\n // If the node has been created in the past, check that\n // the current plugin is the same as the previous.\n if (oldNode && oldNode.internal.owner !== pluginName) {\n throw new Error(\n stripIndent`\n Nodes can only be updated by their owner. Node \"${node.id}\" is\n owned by \"${oldNode.internal.owner}\" and another plugin \"${pluginName}\"\n tried to update it.\n\n `\n )\n }\n }\n\n if (actionOptions.parentSpan) {\n actionOptions.parentSpan.setTag(`nodeId`, node.id)\n actionOptions.parentSpan.setTag(`nodeType`, node.id)\n }\n\n let deleteActions\n let updateNodeAction\n // Check if the node has already been processed.\n if (oldNode && !hasNodeChanged(node.id, node.internal.contentDigest)) {\n updateNodeAction = {\n ...actionOptions,\n plugin,\n type: `TOUCH_NODE`,\n payload: node.id,\n }\n } else {\n // Remove any previously created descendant nodes as they're all due\n // to be recreated.\n if (oldNode) {\n const createDeleteAction = node => {\n return {\n ...actionOptions,\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n deleteActions = findChildren(oldNode.children)\n .map(getNode)\n .map(createDeleteAction)\n }\n\n node.internal.counter = getNextNodeCounter()\n\n updateNodeAction = {\n ...actionOptions,\n type: `CREATE_NODE`,\n plugin,\n oldNode,\n payload: node,\n }\n }\n\n if (deleteActions && deleteActions.length) {\n return [...deleteActions, updateNodeAction]\n } else {\n return updateNodeAction\n }\n}\n\nactions.createNode =\n (...args) =>\n dispatch => {\n const actions = createNode(...args)\n\n dispatch(actions)\n const createNodeAction = (\n Array.isArray(actions) ? actions : [actions]\n ).find(action => action.type === `CREATE_NODE`)\n\n if (!createNodeAction) {\n return Promise.resolve(undefined)\n }\n\n const { payload: node, traceId, parentSpan } = createNodeAction\n const maybePromise = apiRunnerNode(`onCreateNode`, {\n node: wrapNode(node),\n traceId,\n parentSpan,\n traceTags: { nodeId: node.id, nodeType: node.internal.type },\n })\n\n if (maybePromise?.then) {\n return maybePromise.then(res =>\n getDataStore()\n .ready()\n .then(() => res)\n )\n } else {\n return getDataStore()\n .ready()\n .then(() => maybePromise)\n }\n }\n\nconst touchNodeDeprecationWarningDisplayedMessages = new Set()\n\n/**\n * \"Touch\" a node. Tells Gatsby a node still exists and shouldn't\n * be garbage collected. Primarily useful for source plugins fetching\n * nodes from a remote system that can return only nodes that have\n * updated. The source plugin then touches all the nodes that haven't\n * updated but still exist so Gatsby knows to keep them.\n * @param {Object} node A node object. See the \"createNode\" action for more information about the node object details.\n * @example\n * touchNode(node)\n */\nactions.touchNode = (node: any, plugin?: Plugin) => {\n if (node && !typeOwners[node.internal.type]) {\n typeOwners[node.internal.type] = node.internal.owner\n }\n\n const nodeId = node?.id\n\n if (!nodeId) {\n // if we don't have a node id, we don't want to dispatch this action\n return []\n }\n\n return {\n type: `TOUCH_NODE`,\n plugin,\n payload: nodeId,\n }\n}\n\ntype CreateNodeInput = {\n node: Object,\n name?: string,\n value: any,\n}\n/**\n * Extend another node. The new node field is placed under the `fields`\n * key on the extended node object.\n *\n * Once a plugin has claimed a field name the field name can't be used by\n * other plugins. Also since nodes are immutable, you can't mutate the node\n * directly. So to extend another node, use this.\n * @param {Object} $0\n * @param {Object} $0.node the target node object\n * @param {string} $0.name the name for the field\n * @param {any} $0.value the value for the field\n * @example\n * createNodeField({\n * node,\n * name: `happiness`,\n * value: `is sweet graphql queries`\n * })\n *\n * // The field value is now accessible at node.fields.happiness\n */\nactions.createNodeField = (\n { node, name, value }: CreateNodeInput,\n plugin: Plugin,\n actionOptions?: ActionOptions\n) => {\n // Ensure required fields are set.\n if (!node.internal.fieldOwners) {\n node.internal.fieldOwners = {}\n }\n if (!node.fields) {\n node.fields = {}\n }\n\n // Normalized name of the field that will be used in schema\n const schemaFieldName = _.includes(name, `___NODE`)\n ? name.split(`___`)[0]\n : name\n\n // Check that this field isn't owned by another plugin.\n const fieldOwner = node.internal.fieldOwners[schemaFieldName]\n if (fieldOwner && fieldOwner !== plugin.name) {\n throw new Error(\n stripIndent`\n A plugin tried to update a node field that it doesn't own:\n\n Node id: ${node.id}\n Plugin: ${plugin.name}\n name: ${name}\n value: ${value}\n `\n )\n }\n\n // Update node\n node.fields[name] = value\n node.internal.fieldOwners[schemaFieldName] = plugin.name\n node = sanitizeNode(node)\n\n return {\n ...actionOptions,\n type: `ADD_FIELD_TO_NODE`,\n plugin,\n payload: node,\n addedField: name,\n }\n}\n\n/**\n * Creates a link between a parent and child node. This is used when you\n * transform content from a node creating a new child node. You need to add\n * this new child node to the `children` array of the parent but since you\n * don't have direct access to the immutable parent node, use this action\n * instead.\n * @param {Object} $0\n * @param {Object} $0.parent the parent node object\n * @param {Object} $0.child the child node object\n * @example\n * createParentChildLink({ parent: parentNode, child: childNode })\n */\nactions.createParentChildLink = (\n { parent, child }: { parent: any, child: any },\n plugin?: Plugin\n) => {\n if (!parent.children.includes(child.id)) {\n parent.children.push(child.id)\n }\n\n return {\n type: `ADD_CHILD_NODE_TO_PARENT_NODE`,\n plugin,\n payload: parent,\n }\n}\n\n/**\n * Merge additional configuration into the current webpack config. A few\n * configurations options will be ignored if set, in order to try prevent accidental breakage.\n * Specifically, any change to `entry`, `output`, `target`, or `resolveLoaders` will be ignored.\n *\n * For full control over the webpack config, use `replaceWebpackConfig()`.\n *\n * @param {Object} config partial webpack config, to be merged into the current one\n */\nactions.setWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {\n if (config.node?.fs === `empty`) {\n report.warn(\n `[deprecated${\n plugin ? ` ` + plugin.name : ``\n }] node.fs is deprecated. Please set \"resolve.fallback.fs = false\".`\n )\n delete config.node.fs\n config.resolve = config.resolve || {}\n config.resolve.fallback = config.resolve.fallback || {}\n config.resolve.fallback.fs = false\n }\n\n return {\n type: `SET_WEBPACK_CONFIG`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Completely replace the webpack config for the current stage. This can be\n * dangerous and break Gatsby if certain configuration options are changed.\n *\n * Generally only useful for cases where you need to handle config merging logic\n * yourself, in which case consider using `webpack-merge`.\n *\n * @param {Object} config complete webpack config\n */\nactions.replaceWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {\n if (config.node?.fs === `empty`) {\n report.warn(\n `[deprecated${\n plugin ? ` ` + plugin.name : ``\n }] node.fs is deprecated. Please set \"resolve.fallback.fs = false\".`\n )\n delete config.node.fs\n config.resolve = config.resolve || {}\n config.resolve.fallback = config.resolve.fallback || {}\n config.resolve.fallback.fs = false\n }\n\n return {\n type: `REPLACE_WEBPACK_CONFIG`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Set top-level Babel options. Plugins and presets will be ignored. Use\n * setBabelPlugin and setBabelPreset for this.\n * @param {Object} config An options object in the shape of a normal babelrc JavaScript object\n * @example\n * setBabelOptions({\n * options: {\n * sourceMaps: `inline`,\n * }\n * })\n */\nactions.setBabelOptions = (options: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!_.isObject(options)) {\n console.log(`${name} must pass an object to \"setBabelOptions\"`)\n console.log(JSON.stringify(options, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n\n if (!_.isObject(options.options)) {\n console.log(`${name} must pass options to \"setBabelOptions\"`)\n console.log(JSON.stringify(options, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n\n return {\n type: `SET_BABEL_OPTIONS`,\n plugin,\n payload: options,\n }\n}\n\n/**\n * Add new plugins or merge options into existing Babel plugins.\n * @param {Object} config A config object describing the Babel plugin to be added.\n * @param {string} config.name The name of the Babel plugin\n * @param {Object} config.options Options to pass to the Babel plugin.\n * @example\n * setBabelPlugin({\n * name: `@emotion/babel-plugin`,\n * options: {\n * sourceMap: true,\n * },\n * })\n */\nactions.setBabelPlugin = (config: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!config.name) {\n console.log(`${name} must set the name of the Babel plugin`)\n console.log(JSON.stringify(config, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n if (!config.options) {\n config.options = {}\n }\n return {\n type: `SET_BABEL_PLUGIN`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Add new presets or merge options into existing Babel presets.\n * @param {Object} config A config object describing the Babel plugin to be added.\n * @param {string} config.name The name of the Babel preset.\n * @param {Object} config.options Options to pass to the Babel preset.\n * @example\n * setBabelPreset({\n * name: `@babel/preset-react`,\n * options: {\n * pragma: `Glamor.createElement`,\n * },\n * })\n */\nactions.setBabelPreset = (config: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!config.name) {\n console.log(`${name} must set the name of the Babel preset`)\n console.log(JSON.stringify(config, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n if (!config.options) {\n config.options = {}\n }\n return {\n type: `SET_BABEL_PRESET`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * Create a \"job\". This is a long-running process that is generally\n * started as a side-effect to a GraphQL query.\n * [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) uses this for\n * example.\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * createJob({ id: `write file id: 123`, fileName: `something.jpeg` })\n */\nactions.createJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"createJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `CREATE_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * Create a \"job\". This is a long-running process that is generally\n * started as a side-effect to a GraphQL query.\n * [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) uses this for\n * example.\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with name, inputPaths, outputDir and args\n * @param {string} job.name The name of the job you want to execute\n * @param {string[]} job.inputPaths The inputPaths that are needed to run\n * @param {string} job.outputDir The directory where all files are being saved to\n * @param {Object} job.args The arguments the job needs to execute\n * @returns {Promise<object>} Promise to see if the job is done executing\n * @example\n * createJobV2({ name: `IMAGE_PROCESSING`, inputPaths: [`something.jpeg`], outputDir: `public/static`, args: { width: 100, height: 100 } })\n */\nactions.createJobV2 = (job: JobV2, plugin: Plugin) => (dispatch, getState) => {\n const internalJob = createInternalJob(job, plugin)\n\n const maybeWorkerPromise = maybeSendJobToMainProcess(internalJob)\n if (maybeWorkerPromise) {\n return maybeWorkerPromise\n }\n\n return createJobV2FromInternalJob(internalJob)(dispatch, getState)\n}\n\nactions.addGatsbyImageSourceUrl = (sourceUrl: string) => {\n return {\n type: `PROCESS_GATSBY_IMAGE_SOURCE_URL`,\n payload: { sourceUrl },\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * Set (update) a \"job\". Sometimes on really long running jobs you want\n * to update the job as it continues.\n *\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * setJob({ id: `write file id: 123`, progress: 50 })\n */\nactions.setJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"setJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `SET_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * End a \"job\".\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * endJob({ id: `write file id: 123` })\n */\nactions.endJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"endJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `END_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * Set plugin status. A plugin can use this to save status keys e.g. the last\n * it fetched something. These values are persisted between runs of Gatsby.\n *\n * @param {Object} status An object with arbitrary values set\n * @example\n * setPluginStatus({ lastFetched: Date.now() })\n */\nactions.setPluginStatus = (\n status: { [key: string]: mixed },\n plugin: Plugin\n) => {\n return {\n type: `SET_PLUGIN_STATUS`,\n plugin,\n payload: status,\n }\n}\n\n// Check if path is absolute and add pathPrefix in front if it's not\nconst maybeAddPathPrefix = (path, pathPrefix) => {\n const parsed = url.parse(path)\n const isRelativeProtocol = path.startsWith(`//`)\n return `${\n parsed.protocol != null || isRelativeProtocol ? `` : pathPrefix\n }${path}`\n}\n\n/**\n * Create a redirect from one page to another. Redirects work out of the box with Gatsby Cloud. Read more about\n * [working with redirects on Gatsby Cloud](https://support.gatsbyjs.com/hc/en-us/articles/1500003051241-Working-with-Redirects).\n * If you are hosting somewhere other than Gatsby Cloud, you will need a plugin to integrate the redirect data with\n * your hosting technology e.g. the [Netlify\n * plugin](/plugins/gatsby-plugin-netlify/), or the [Amazon S3\n * plugin](/plugins/gatsby-plugin-s3/). Alternatively, you can use\n * [this plugin](/plugins/gatsby-plugin-meta-redirect/) to generate meta redirect\n * html files for redirecting on any static file host.\n *\n * @param {Object} redirect Redirect data\n * @param {string} redirect.fromPath Any valid URL. Must start with a forward slash\n * @param {boolean} redirect.isPermanent This is a permanent redirect; defaults to temporary\n * @param {string} redirect.toPath URL of a created page (see `createPage`)\n * @param {boolean} redirect.redirectInBrowser Redirects are generally for redirecting legacy URLs to their new configuration on the server. If you can't update your UI for some reason, set `redirectInBrowser` to true and Gatsby will handle redirecting in the client as well. You almost never need this so be sure your use case fits before enabling.\n * @param {boolean} redirect.force (Plugin-specific) Will trigger the redirect even if the `fromPath` matches a piece of content. This is not part of the Gatsby API, but implemented by (some) plugins that configure hosting provider redirects\n * @param {number} redirect.statusCode (Plugin-specific) Manually set the HTTP status code. This allows you to create a rewrite (status code 200) or custom error page (status code 404). Note that this will override the `isPermanent` option which also sets the status code. This is not part of the Gatsby API, but implemented by (some) plugins that configure hosting provider redirects\n * @param {boolean} redirect.ignoreCase (Plugin-specific) Ignore case when looking for redirects\n * @param {Object} redirect.conditions Specify a country or language based redirect\n * @param {(string|string[])} redirect.conditions.country A two-letter country code based on the regional indicator symbol\n * @param {(string|string[])} redirect.conditions.language A two-letter identifier defined by ISO 639-1\n * @example\n * // Generally you create redirects while creating pages.\n * exports.createPages = ({ graphql, actions }) => {\n * const { createRedirect } = actions\n * createRedirect({ fromPath: '/old-url', toPath: '/new-url', isPermanent: true })\n * createRedirect({ fromPath: '/url', toPath: '/zn-CH/url', conditions: { language: 'zn' }})\n * createRedirect({ fromPath: '/url', toPath: '/en/url', conditions: { language: ['ca', 'us'] }})\n * createRedirect({ fromPath: '/url', toPath: '/ca/url', conditions: { country: 'ca' }})\n * createRedirect({ fromPath: '/url', toPath: '/en/url', conditions: { country: ['ca', 'us'] }})\n * createRedirect({ fromPath: '/not_so-pretty_url', toPath: '/pretty/url', statusCode: 200 })\n * // Create pages here\n * }\n */\nactions.createRedirect = ({\n fromPath,\n isPermanent = false,\n redirectInBrowser = false,\n toPath,\n ignoreCase = true,\n ...rest\n}) => {\n let pathPrefix = ``\n if (store.getState().program.prefixPaths) {\n pathPrefix = store.getState().config.pathPrefix\n }\n\n return {\n type: `CREATE_REDIRECT`,\n payload: {\n fromPath: maybeAddPathPrefix(fromPath, pathPrefix),\n isPermanent,\n ignoreCase,\n redirectInBrowser,\n toPath: maybeAddPathPrefix(toPath, pathPrefix),\n ...rest,\n },\n }\n}\n\n/**\n * Create a dependency between a page and data.\n *\n * @param {Object} $0\n * @param {string} $0.path the path to the page\n * @param {string} $0.nodeId A node ID\n * @param {string} $0.connection A connection type\n * @private\n */\nactions.createPageDependency = (\n {\n path,\n nodeId,\n connection,\n }: { path: string, nodeId: string, connection: string },\n plugin: string = ``\n) => {\n console.warn(\n `Calling \"createPageDependency\" directly from actions in deprecated. Use \"createPageDependency\" from \"gatsby/dist/redux/actions/add-page-dependency\".`\n )\n return {\n type: `CREATE_COMPONENT_DEPENDENCY`,\n plugin,\n payload: [\n {\n path,\n nodeId,\n connection,\n },\n ],\n }\n}\n\n/**\n * Record that a page was visited on the server..\n *\n * @param {Object} $0\n * @param {string} $0.id the chunkName for the page component.\n */\nactions.createServerVisitedPage = (chunkName: string) => {\n if (store.getState().visitedPages.get(`server`)?.has(chunkName)) {\n // we already have given chunk tracked, let's not emit `CREATE_SERVER_VISITED_PAGE`\n // action to not cause any additional work\n return []\n }\n\n return {\n type: `CREATE_SERVER_VISITED_PAGE`,\n payload: { componentChunkName: chunkName },\n }\n}\n\n/**\n * Creates an individual node manifest.\n * This is used to tie the unique revision state within a data source at the current point in time to a page generated from the provided node when it's node manifest is processed.\n *\n * @param {Object} manifest Manifest data\n * @param {string} manifest.manifestId An id which ties the unique revision state of this manifest to the unique revision state of a data source.\n * @param {Object} manifest.node The Gatsby node to tie the manifestId to. See the \"createNode\" action for more information about the node object details.\n * @param {string} manifest.updatedAtUTC (optional) The time in which the node was last updated. If this parameter is not included, a manifest is created for every node that gets called. By default, node manifests are created for content updated in the last 30 days. To change this, set a `NODE_MANIFEST_MAX_DAYS_OLD` environment variable.\n * @example\n * unstable_createNodeManifest({\n * manifestId: `post-id-1--updated-53154315`,\n * updatedAtUTC: `2021-07-08T21:52:28.791+01:00`,\n * node: {\n * id: `post-id-1`\n * },\n * })\n */\nactions.unstable_createNodeManifest = (\n { manifestId, node, updatedAtUTC },\n plugin: Plugin\n) => {\n return {\n type: `CREATE_NODE_MANIFEST`,\n payload: {\n manifestId,\n node,\n pluginName: plugin.name,\n updatedAtUTC,\n },\n }\n}\n\n/**\n * Stores request headers for a given domain to be later used when making requests for Image CDN (and potentially other features).\n *\n * @param {Object} $0\n * @param {string} $0.domain The domain to store the headers for.\n * @param {Object} $0.headers The headers to store.\n */\nactions.setRequestHeaders = ({ domain, headers }, plugin: Plugin) => {\n const headersIsObject =\n typeof headers === `object` && headers !== null && !Array.isArray(headers)\n\n const noHeaders = !headersIsObject\n const noDomain = typeof domain !== `string`\n\n if (noHeaders) {\n reporter.warn(\n `Plugin ${plugin.name} called actions.setRequestHeaders with a headers property that isn't an object.`\n )\n }\n\n if (noDomain) {\n reporter.warn(\n `Plugin ${plugin.name} called actions.setRequestHeaders with a domain property that isn't a string.`\n )\n }\n\n if (noDomain || noHeaders) {\n reporter.panic(\n `Plugin ${plugin.name} attempted to set request headers with invalid arguments. See above warnings for more info.`\n )\n\n return null\n }\n\n const baseDomain = url.parse(domain)?.hostname\n\n if (baseDomain) {\n return {\n type: `SET_REQUEST_HEADERS`,\n payload: {\n domain: baseDomain,\n headers,\n },\n }\n } else {\n reporter.panic(\n `Plugin ${plugin.name} attempted to set request headers for a domain that is not a valid URL. (${domain})`\n )\n\n return null\n }\n}\n\nmodule.exports = { actions }\n"],"mappings":";;;;AAiBA;;AAGA;;AAaA;;AACA;;AACA;;AACA;;AAnCA,MAAMA,QAAQ,GAAGC,OAAO,CAAE,yBAAF,CAAxB;;AACA,MAAMC,KAAK,GAAGD,OAAO,CAAE,OAAF,CAArB;;AACA,MAAME,CAAC,GAAGF,OAAO,CAAE,QAAF,CAAjB;;AACA,MAAM;EAAEG;AAAF,IAAkBH,OAAO,CAAE,aAAF,CAA/B;;AACA,MAAMI,MAAM,GAAGJ,OAAO,CAAE,yBAAF,CAAtB;;AACA,MAAM;EAAEK;AAAF,IAAeL,OAAO,CAAE,IAAF,CAA5B;;AACA,MAAMM,IAAI,GAAGN,OAAO,CAAE,MAAF,CAApB;;AACA,MAAM;EAAEO;AAAF,IAAuBP,OAAO,CAAE,gBAAF,CAApC;;AACA,MAAMQ,GAAG,GAAGR,OAAO,CAAE,KAAF,CAAnB;;AACA,MAAM;EAAES;AAAF,IAAYT,OAAO,CAAE,wBAAF,CAAzB;;AACA,MAAM;EACJU;AADI,IAEFV,OAAO,CAAE,yCAAF,CAFX;;AAGA,MAAM;EAAEW;AAAF,IAAyBX,OAAO,CAAE,wCAAF,CAAtC;;AACA,MAAM;EAAEY;AAAF,IAAqBZ,OAAO,CAAE,mBAAF,CAAlC;;AACA,MAAM;EAAEa,OAAF;EAAWC;AAAX,IAA4Bd,OAAO,CAAE,iBAAF,CAAzC;;AAEA,MAAM;EAAEe;AAAF,IAAYf,OAAO,CAAE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CAACgH,YAAY,CAAC9G,QAAd,CAAZ,CAAoCkC,GAApC,CAAwCvE,OAAxC,EAAiDuE,GAAjD,CAAqDqE,kBAArD,CAFF;;EAIA,IAAIW,wBAAwB,IAAIA,wBAAwB,CAACxH,MAAzD,EAAiE;IAC/D,OAAO,CAAC,GAAGwH,wBAAJ,EAA8BD,YAA9B,CAAP;EACD,CAFD,MAEO;IACL,OAAOA,YAAP;EACD;AACF,CApDD,C,CAsDA;AACA;;;AACA,SAASR,kBAAT,GAA8B;EAAA;;EAC5B,MAAMU,eAAe,4BAAGtJ,KAAK,CAACgF,QAAN,GAAiBuE,MAAjB,CAAwBC,iBAA3B,yEAAgD,CAArE;;EACA,IAAIF,eAAe,IAAIG,MAAM,CAACC,gBAA9B,EAAgD;IAC9C,MAAM,IAAIP,KAAJ,CACH,+DAA8DG,eAAgB,EAD3E,CAAN;EAGD;;EACD,OAAOA,eAAe,GAAG,CAAzB;AACD;;AAED,MAAMJ,UAAU,GAAG,EAAnB,C,CAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMS,UAAU,GAAG,CACjBvB,IADiB,EAEjB1E,MAFiB,EAGjBC,aAA6B,GAAG,EAHf,KAId;EACH,IAAI,CAACxE,CAAC,CAACyK,QAAF,CAAWxB,IAAX,CAAL,EAAuB;IACrB,OAAOyB,OAAO,CAACC,GAAR,CACL5K,KAAK,CAACgJ,IAAN,CAAW6B,GAAX,CACG,s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,iBAAG5Q,GAAG,CAACkP,KAAJ,CAAUqB,MAAV,CAAH,+CAAG,WAAmBM,QAAtC;;EAEA,IAAID,UAAJ,EAAgB;IACd,OAAO;MACLpN,IAAI,EAAG,qBADF;MAELC,OAAO,EAAE;QACP8M,MAAM,EAAEK,UADD;QAEPJ;MAFO;IAFJ,CAAP;EAOD,CARD,MAQO;IACLjR,QAAQ,CAAC8E,KAAT,CACG,UAASJ,MAAM,CAACE,IAAK,4EAA2EoM,MAAO,GAD1G;IAIA,OAAO,IAAP;EACD;AACF,CA5CD;;AA8CAO,MAAM,CAACC,OAAP,GAAiB;EAAEnP;AAAF,CAAjB"}
1
+ {"version":3,"file":"public.js","names":["reporter","require","chalk","_","stripIndent","report","platform","path","trueCasePathSync","url","slash","createContentDigest","splitComponentPath","hasNodeChanged","getNode","getDataStore","store","validateComponent","generateComponentChunkName","getCommonDir","truncatePath","tooLongSegmentsInPath","applyTrailingSlashOption","apiRunnerNode","trackCli","getNonGatsbyCodeFrame","getPageMode","normalizePath","default","isNotTestEnv","process","env","NODE_ENV","isTestEnv","shadowCreatePagePath","memoize","createInternalJob","actions","isWindows","ensureWindowsDriveIsUppercase","filePath","segments","split","filter","s","length","shift","toUpperCase","join","findChildren","initialChildren","children","queue","traversedNodes","Set","currentChild","pop","has","id","add","newChildren","isArray","push","deletePage","page","type","payload","hasWarnedForPageComponentInvalidContext","hasWarnedForPageComponentInvalidCasing","hasErroredBecauseOfNodeValidation","pageComponentCache","Map","reservedFields","createPage","plugin","actionOptions","name","message","panic","context","pluginName","pageObject","invalidFields","field","error","map","f","JSON","stringify","some","component","warn","input","pageComponentPath","config","program","getState","trailingSlash","directory","panicOnBuild","errorIdMap","noPath","notAbsolute","doesNotExist","empty","noDefaultExport","get","originalPageComponent","splitPath","trueComponentPath","e","commonDir","relativePath","win32","relative","markers","letter","index","set","internalComponentName","invalidPathSegments","truncatedPath","internalPage","matchPath","componentPath","componentChunkName","isCreatedByStatefulCreatePages","traceId","updatedAt","Date","now","slices","pluginCreator___NODE","pluginCreatorId","defer","mode","ownerNodeId","oldPage","pages","contextModified","isEqual","componentModified","slicesModified","alternateSlashPath","endsWith","slice","bold","yellow","node","internal","contentDigest","oldNode","deleteActions","updateNodeAction","createDeleteAction","counter","getNextNodeCounter","sanitizedPayload","sanitizeNode","deleteNodeDeprecationWarningDisplayedMessages","deleteNode","internalNode","typeOwners","Error","deleteAction","deleteDescendantsActions","lastNodeCounter","status","LAST_NODE_COUNTER","Number","MAX_SAFE_INTEGER","createNode","isObject","console","log","red","array","parent","owner","trackParams","version","debounce","result","nodeSchema","validate","errorObj","validationErrorMessage","possiblyCodeFrame","codeFrame","fileName","location","start","line","column","fields","parentSpan","setTag","args","dispatch","createNodeAction","Array","find","action","Promise","resolve","undefined","maybePromise","wrapNode","traceTags","nodeId","nodeType","then","res","ready","touchNodeDeprecationWarningDisplayedMessages","touchNode","createNodeField","value","fieldOwners","schemaFieldName","includes","fieldOwner","addedField","createParentChildLink","child","setWebpackConfig","fs","fallback","replaceWebpackConfig","setBabelOptions","options","exit","setBabelPlugin","setBabelPreset","createJob","job","msg","reportOnce","createJobV2","internalJob","maybeWorkerPromise","maybeSendJobToMainProcess","createJobV2FromInternalJob","addGatsbyImageSourceUrl","sourceUrl","setJob","endJob","setPluginStatus","maybeAddPathPrefix","pathPrefix","parsed","parse","isRelativeProtocol","startsWith","protocol","createRedirect","fromPath","isPermanent","redirectInBrowser","toPath","ignoreCase","rest","prefixPaths","createPageDependency","connection","createServerVisitedPage","chunkName","visitedPages","unstable_createNodeManifest","manifestId","updatedAtUTC","setRequestHeaders","domain","headers","headersIsObject","noHeaders","noDomain","baseDomain","hostname","module","exports"],"sources":["../../../src/redux/actions/public.js"],"sourcesContent":["// @flow\nconst reporter = require(`gatsby-cli/lib/reporter`)\nconst chalk = require(`chalk`)\nconst _ = require(`lodash`)\nconst { stripIndent } = require(`common-tags`)\nconst report = require(`gatsby-cli/lib/reporter`)\nconst { platform } = require(`os`)\nconst path = require(`path`)\nconst { trueCasePathSync } = require(`true-case-path`)\nconst url = require(`url`)\nconst { slash } = require(`gatsby-core-utils/path`)\nconst {\n createContentDigest,\n} = require(`gatsby-core-utils/create-content-digest`)\nconst { splitComponentPath } = require(`gatsby-core-utils/parse-component-path`)\nconst { hasNodeChanged } = require(`../../utils/nodes`)\nconst { getNode, getDataStore } = require(`../../datastore`)\nimport { sanitizeNode } from \"../../utils/sanitize-node\"\nconst { store } = require(`../index`)\nconst { validateComponent } = require(`../../utils/validate-component`)\nimport { nodeSchema } from \"../../joi-schemas/joi\"\nconst { generateComponentChunkName } = require(`../../utils/js-chunk-names`)\nconst {\n getCommonDir,\n truncatePath,\n tooLongSegmentsInPath,\n} = require(`../../utils/path`)\nconst { applyTrailingSlashOption } = require(`gatsby-page-utils`)\nconst apiRunnerNode = require(`../../utils/api-runner-node`)\nconst { trackCli } = require(`gatsby-telemetry`)\nconst { getNonGatsbyCodeFrame } = require(`../../utils/stack-trace-utils`)\nconst { getPageMode } = require(`../../utils/page-mode`)\nconst normalizePath = require(`../../utils/normalize-path`).default\nimport { createJobV2FromInternalJob } from \"./internal\"\nimport { maybeSendJobToMainProcess } from \"../../utils/jobs/worker-messaging\"\nimport { reportOnce } from \"../../utils/report-once\"\nimport { wrapNode } from \"../../utils/detect-node-mutations\"\n\nconst isNotTestEnv = process.env.NODE_ENV !== `test`\nconst isTestEnv = process.env.NODE_ENV === `test`\n\n// Memoize function used to pick shadowed page components to avoid expensive I/O.\n// Ideally, we should invalidate memoized values if there are any FS operations\n// on files that are in shadowing chain, but webpack currently doesn't handle\n// shadowing changes during develop session, so no invalidation is not a deal breaker.\nconst shadowCreatePagePath = _.memoize(\n require(`../../internal-plugins/webpack-theme-component-shadowing/create-page`)\n)\nconst { createInternalJob } = require(`../../utils/jobs/manager`)\n\nconst actions = {}\nconst isWindows = platform() === `win32`\n\nconst ensureWindowsDriveIsUppercase = filePath => {\n const segments = filePath.split(`:`).filter(s => s !== ``)\n return segments.length > 0\n ? segments.shift().toUpperCase() + `:` + segments.join(`:`)\n : filePath\n}\n\nconst findChildren = initialChildren => {\n const children = [...initialChildren]\n const queue = [...initialChildren]\n const traversedNodes = new Set()\n\n while (queue.length > 0) {\n const currentChild = getNode(queue.pop())\n if (!currentChild || traversedNodes.has(currentChild.id)) {\n continue\n }\n traversedNodes.add(currentChild.id)\n const newChildren = currentChild.children\n if (_.isArray(newChildren) && newChildren.length > 0) {\n children.push(...newChildren)\n queue.push(...newChildren)\n }\n }\n return children\n}\n\nimport type { Plugin } from \"./types\"\n\ntype Job = {\n id: string,\n}\n\ntype JobV2 = {\n name: string,\n inputPaths: string[],\n outputDir: string,\n args: Object,\n}\n\nexport interface IPageInput {\n path: string;\n component: string;\n context?: Object;\n ownerNodeId?: string;\n defer?: boolean;\n slices: Record<string, string>;\n}\n\ntype PageMode = \"SSG\" | \"DSG\" | \"SSR\"\n\ntype Page = {\n path: string,\n matchPath: ?string,\n component: string,\n context: Object,\n internalComponentName: string,\n componentChunkName: string,\n updatedAt: number,\n ownerNodeId?: string,\n mode: PageMode,\n slices: Record<string, string>,\n}\n\ntype ActionOptions = {\n traceId: ?string,\n parentSpan: ?Object,\n followsSpan: ?Object,\n}\n\ntype PageData = {\n id: string,\n resultHash: string,\n}\n\ntype PageDataRemove = {\n id: string,\n}\n\n/**\n * Delete a page\n * @param {Object} page a page object\n * @param {string} page.path The path of the page\n * @param {string} page.component The absolute path to the page component\n * @example\n * deletePage(page)\n */\nactions.deletePage = (page: IPageInput) => {\n return {\n type: `DELETE_PAGE`,\n payload: page,\n }\n}\n\nconst hasWarnedForPageComponentInvalidContext = new Set()\nconst hasWarnedForPageComponentInvalidCasing = new Set()\nconst hasErroredBecauseOfNodeValidation = new Set()\nconst pageComponentCache = new Map()\nconst reservedFields = [\n `path`,\n `matchPath`,\n `component`,\n `componentChunkName`,\n `pluginCreator___NODE`,\n `pluginCreatorId`,\n]\n/**\n * Create a page. See [the guide on creating and modifying pages](/docs/creating-and-modifying-pages/)\n * for detailed documentation about creating pages.\n * @param {Object} page a page object\n * @param {string} page.path Any valid URL. Must start with a forward slash. Unicode characters should be passed directly and not encoded (eg. `á` not `%C3%A1`).\n * @param {string} page.matchPath Path that Reach Router uses to match the page on the client side.\n * Also see docs on [matchPath](/docs/gatsby-internals-terminology/#matchpath)\n * @param {string} page.ownerNodeId The id of the node that owns this page. This is used for routing users to previews via the unstable_createNodeManifest public action. Since multiple nodes can be queried on a single page, this allows the user to tell us which node is the main node for the page. Note that the ownerNodeId must be for a node which is queried on this page via a GraphQL query.\n * @param {string} page.component The absolute path to the component for this page\n * @param {Object} page.context Context data for this page. Passed as props\n * to the component `this.props.pageContext` as well as to the graphql query\n * as graphql arguments.\n * @param {Object} page.slices A mapping of alias-of-id for Slices rendered on this page. See the technical docs for the [Gatsby Slice API](/docs/reference/built-in-components/gatsby-slice).\n * @param {boolean} page.defer When set to `true`, Gatsby will exclude the page from the build step and instead generate it during the first HTTP request. Default value is `false`. Also see docs on [Deferred Static Generation](/docs/reference/rendering-options/deferred-static-generation/).\n * @example\n * createPage({\n * path: `/my-sweet-new-page/`,\n * component: path.resolve(`./src/templates/my-sweet-new-page.js`),\n * ownerNodeId: `123456`,\n * // The context is passed as props to the component as well\n * // as into the component's GraphQL query.\n * context: {\n * id: `123456`,\n * },\n * })\n */\nactions.createPage = (\n page: IPageInput,\n plugin?: Plugin,\n actionOptions?: ActionOptions\n) => {\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!page.path) {\n const message = `${name} must set the page path when creating a page`\n // Don't log out when testing\n if (isNotTestEnv) {\n report.panic({\n id: `11323`,\n context: {\n pluginName: name,\n pageObject: page,\n message,\n },\n })\n } else {\n return message\n }\n }\n\n // Validate that the context object doesn't overlap with any core page fields\n // as this will cause trouble when running graphql queries.\n if (page.context && typeof page.context === `object`) {\n const invalidFields = reservedFields.filter(field => field in page.context)\n\n if (invalidFields.length > 0) {\n const error = `${\n invalidFields.length === 1\n ? `${name} used a reserved field name in the context object when creating a page:`\n : `${name} used reserved field names in the context object when creating a page:`\n }\n\n${invalidFields.map(f => ` * \"${f}\"`).join(`\\n`)}\n\n${JSON.stringify(page, null, 4)}\n\nData in \"context\" is passed to GraphQL as potential arguments when running the\npage query.\n\nWhen arguments for GraphQL are constructed, the context object is combined with\nthe page object so *both* page object and context data are available as\narguments. So you don't need to add the page \"path\" to the context as it's\nalready available in GraphQL. If a context field duplicates a field already\nused by the page object, this can break functionality within Gatsby so must be\navoided.\n\nPlease choose another name for the conflicting fields.\n\nThe following fields are used by the page object and should be avoided.\n\n${reservedFields.map(f => ` * \"${f}\"`).join(`\\n`)}\n\n `\n if (isTestEnv) {\n return error\n // Only error if the context version is different than the page\n // version. People in v1 often thought that they needed to also pass\n // the path to context for it to be available in GraphQL\n } else if (invalidFields.some(f => page.context[f] !== page[f])) {\n report.panic({\n id: `11324`,\n context: {\n message: error,\n },\n })\n } else {\n if (!hasWarnedForPageComponentInvalidContext.has(page.component)) {\n report.warn(error)\n hasWarnedForPageComponentInvalidContext.add(page.component)\n }\n }\n }\n }\n\n // Check if a component is set.\n if (!page.component) {\n if (isNotTestEnv) {\n report.panic({\n id: `11322`,\n context: {\n input: page,\n pluginName: name,\n },\n })\n } else {\n // For test\n return `A component must be set when creating a page`\n }\n }\n\n const pageComponentPath = shadowCreatePagePath(page.component)\n if (pageComponentPath) {\n page.component = pageComponentPath\n }\n\n const { config, program } = store.getState()\n const { trailingSlash } = config\n const { directory } = program\n\n const { error, panicOnBuild } = validateComponent({\n input: page,\n pluginName: name,\n errorIdMap: {\n noPath: `11322`,\n notAbsolute: `11326`,\n doesNotExist: `11325`,\n empty: `11327`,\n noDefaultExport: `11328`,\n },\n })\n\n if (error) {\n if (isNotTestEnv) {\n if (panicOnBuild) {\n report.panicOnBuild(error)\n } else {\n report.panic(error)\n }\n }\n return `${name} must set the absolute path to the page component when creating a page`\n }\n\n // check if we've processed this component path\n // before, before running the expensive \"trueCasePath\"\n // operation\n //\n // Skip during testing as the paths don't exist on disk.\n if (isNotTestEnv) {\n if (pageComponentCache.has(page.component)) {\n page.component = pageComponentCache.get(page.component)\n } else {\n const originalPageComponent = page.component\n const splitPath = splitComponentPath(page.component)\n\n // normalize component path\n page.component = slash(splitPath[0])\n // check if path uses correct casing - incorrect casing will\n // cause issues in query compiler and inconsistencies when\n // developing on Mac or Windows and trying to deploy from\n // linux CI/CD pipeline\n let trueComponentPath\n try {\n // most systems\n trueComponentPath = slash(trueCasePathSync(page.component))\n } catch (e) {\n // systems where user doesn't have access to /\n const commonDir = getCommonDir(directory, page.component)\n\n // using `path.win32` to force case insensitive relative path\n const relativePath = slash(\n path.win32.relative(commonDir, page.component)\n )\n\n trueComponentPath = slash(trueCasePathSync(relativePath, commonDir))\n }\n\n if (isWindows) {\n page.component = ensureWindowsDriveIsUppercase(page.component)\n }\n\n if (trueComponentPath !== page.component) {\n if (!hasWarnedForPageComponentInvalidCasing.has(page.component)) {\n const markers = page.component\n .split(``)\n .map((letter, index) => {\n if (letter !== trueComponentPath[index]) {\n return `^`\n }\n return ` `\n })\n .join(``)\n\n report.warn(\n stripIndent`\n ${name} created a page with a component path that doesn't match the casing of the actual file. This may work locally, but will break on systems which are case-sensitive, e.g. most CI/CD pipelines.\n\n page.component: \"${page.component}\"\n path in filesystem: \"${trueComponentPath}\"\n ${markers}\n `\n )\n hasWarnedForPageComponentInvalidCasing.add(page.component)\n }\n\n page.component = trueComponentPath\n }\n\n if (splitPath.length > 1) {\n page.component = `${page.component}?__contentFilePath=${splitPath[1]}`\n }\n\n pageComponentCache.set(originalPageComponent, page.component)\n }\n }\n\n let internalComponentName\n if (page.path === `/`) {\n internalComponentName = `ComponentIndex`\n } else {\n internalComponentName = `Component${page.path}`\n }\n\n const invalidPathSegments = tooLongSegmentsInPath(page.path)\n\n if (invalidPathSegments.length > 0) {\n const truncatedPath = truncatePath(page.path)\n report.warn(\n report.stripIndent(`\n The path to the following page is longer than the supported limit on most\n operating systems and will cause an ENAMETOOLONG error. The path has been\n truncated to prevent this.\n\n Original Path: ${page.path}\n\n Truncated Path: ${truncatedPath}\n `)\n )\n page.path = truncatedPath\n }\n\n page.path = applyTrailingSlashOption(page.path, trailingSlash)\n\n const internalPage: Page = {\n internalComponentName,\n path: page.path,\n matchPath: page.matchPath,\n component: normalizePath(page.component),\n componentPath: normalizePath(page.component),\n componentChunkName: generateComponentChunkName(page.component),\n isCreatedByStatefulCreatePages:\n actionOptions?.traceId === `initial-createPagesStatefully`,\n // Ensure the page has a context object\n context: page.context || {},\n updatedAt: Date.now(),\n slices: page?.slices || {},\n\n // Link page to its plugin.\n pluginCreator___NODE: plugin.id ?? ``,\n pluginCreatorId: plugin.id ?? ``,\n }\n\n if (page.defer) {\n internalPage.defer = true\n }\n // Note: mode is updated in the end of the build after we get access to all page components,\n // see materializePageMode in utils/page-mode.ts\n internalPage.mode = getPageMode(internalPage)\n\n if (page.ownerNodeId) {\n internalPage.ownerNodeId = page.ownerNodeId\n }\n\n // If the path doesn't have an initial forward slash, add it.\n if (internalPage.path[0] !== `/`) {\n internalPage.path = `/${internalPage.path}`\n }\n\n const oldPage: Page = store.getState().pages.get(internalPage.path)\n const contextModified =\n !!oldPage && !_.isEqual(oldPage.context, internalPage.context)\n const componentModified =\n !!oldPage && !_.isEqual(oldPage.component, internalPage.component)\n const slicesModified =\n !!oldPage && !_.isEqual(oldPage.slices, internalPage.slices)\n\n const alternateSlashPath = page.path.endsWith(`/`)\n ? page.path.slice(0, -1)\n : page.path + `/`\n\n if (store.getState().pages.has(alternateSlashPath)) {\n report.warn(\n chalk.bold.yellow(`Non-deterministic routing danger: `) +\n `Attempting to create page: \"${page.path}\", but page \"${alternateSlashPath}\" already exists\\n` +\n chalk.bold.yellow(\n `This could lead to non-deterministic routing behavior`\n )\n )\n }\n\n // just so it's easier to c&p from createPage action creator for now - ideally it's DRYed\n const { updatedAt, ...node } = internalPage\n node.children = []\n node.internal = {\n type: `SitePage`,\n contentDigest: createContentDigest(node),\n }\n node.id = `SitePage ${internalPage.path}`\n const oldNode = getNode(node.id)\n\n let deleteActions\n let updateNodeAction\n if (oldNode && !hasNodeChanged(node.id, node.internal.contentDigest)) {\n updateNodeAction = {\n ...actionOptions,\n plugin,\n type: `TOUCH_NODE`,\n payload: node.id,\n }\n } else {\n // Remove any previously created descendant nodes as they're all due\n // to be recreated.\n if (oldNode) {\n const createDeleteAction = node => {\n return {\n ...actionOptions,\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n deleteActions = findChildren(oldNode.children)\n .map(getNode)\n .map(createDeleteAction)\n }\n\n node.internal.counter = getNextNodeCounter()\n\n updateNodeAction = {\n ...actionOptions,\n type: `CREATE_NODE`,\n plugin,\n oldNode,\n payload: node,\n }\n }\n\n // Sanitize page object so we don't attempt to serialize user-provided objects that are not serializable later\n const sanitizedPayload = sanitizeNode(internalPage)\n\n const actions = [\n {\n ...actionOptions,\n type: `CREATE_PAGE`,\n contextModified,\n componentModified,\n slicesModified,\n plugin,\n payload: sanitizedPayload,\n },\n ]\n\n if (deleteActions && deleteActions.length) {\n actions.push(...deleteActions)\n }\n\n actions.push(updateNodeAction)\n\n return actions\n}\n\nconst deleteNodeDeprecationWarningDisplayedMessages = new Set()\n\n/**\n * Delete a node\n * @param {object} node A node object. See the \"createNode\" action for more information about the node object details.\n * @example\n * deleteNode(node)\n */\nactions.deleteNode = (node: any, plugin?: Plugin) => {\n const id = node && node.id\n\n // Always get node from the store, as the node we get as an arg\n // might already have been deleted.\n const internalNode = getNode(id)\n if (plugin) {\n const pluginName = plugin.name\n\n if (\n internalNode &&\n typeOwners[internalNode.internal.type] &&\n typeOwners[internalNode.internal.type] !== pluginName\n )\n throw new Error(stripIndent`\n The plugin \"${pluginName}\" deleted a node of a type owned by another plugin.\n\n The node type \"${internalNode.internal.type}\" is owned by \"${\n typeOwners[internalNode.internal.type]\n }\".\n\n The node object passed to \"deleteNode\":\n\n ${JSON.stringify(internalNode, null, 4)}\n\n The plugin deleting the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `)\n }\n\n const createDeleteAction = node => {\n return {\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n\n const deleteAction = createDeleteAction(internalNode)\n\n // It's possible the file node was never created as sometimes tools will\n // write and then immediately delete temporary files to the file system.\n const deleteDescendantsActions =\n internalNode &&\n findChildren(internalNode.children).map(getNode).map(createDeleteAction)\n\n if (deleteDescendantsActions && deleteDescendantsActions.length) {\n return [...deleteDescendantsActions, deleteAction]\n } else {\n return deleteAction\n }\n}\n\n// We add a counter to node.internal for fast comparisons/intersections\n// of various node slices. The counter must increase even across builds.\nfunction getNextNodeCounter() {\n const lastNodeCounter = store.getState().status.LAST_NODE_COUNTER ?? 0\n if (lastNodeCounter >= Number.MAX_SAFE_INTEGER) {\n throw new Error(\n `Could not create more nodes. Maximum node count is reached: ${lastNodeCounter}`\n )\n }\n return lastNodeCounter + 1\n}\n\nconst typeOwners = {}\n\n// memberof notation is added so this code can be referenced instead of the wrapper.\n/**\n * Create a new node.\n * @memberof actions\n * @param {Object} node a node object\n * @param {string} node.id The node's ID. Must be globally unique.\n * @param {string} node.parent The ID of the parent's node. If the node is\n * derived from another node, set that node as the parent. Otherwise it can\n * just be `null`.\n * @param {Array} node.children An array of children node IDs. If you're\n * creating the children nodes while creating the parent node, add the\n * children node IDs here directly. If you're adding a child node to a\n * parent node created by a plugin, you can't mutate this value directly\n * to add your node id, instead use the action creator `createParentChildLink`.\n * @param {Object} node.internal node fields that aren't generally\n * interesting to consumers of node data but are very useful for plugin writers\n * and Gatsby core. Only fields described below are allowed in `internal` object.\n * Using any type of custom fields will result in validation errors.\n * @param {string} node.internal.mediaType An optional field to indicate to\n * transformer plugins that your node has raw content they can transform.\n * Use either an official media type (we use mime-db as our source\n * (https://www.npmjs.com/package/mime-db) or a made-up one if your data\n * doesn't fit in any existing bucket. Transformer plugins use node media types\n * for deciding if they should transform a node into a new one. E.g.\n * markdown transformers look for media types of\n * `text/markdown`.\n * @param {string} node.internal.type An arbitrary globally unique type\n * chosen by the plugin creating the node. Should be descriptive of the\n * node as the type is used in forming GraphQL types so users will query\n * for nodes based on the type chosen here. Nodes of a given type can\n * only be created by one plugin.\n * @param {string} node.internal.content An optional field. This is rarely\n * used. It is used when a source plugin sources data it doesn't know how\n * to transform e.g. a markdown string pulled from an API. The source plugin\n * can defer the transformation to a specialized transformer plugin like\n * gatsby-transformer-remark. This `content` field holds the raw content\n * (so for the markdown case, the markdown string).\n *\n * Data that's already structured should be added to the top-level of the node\n * object and _not_ added here. You should not `JSON.stringify` your node's\n * data here.\n *\n * If the content is very large and can be lazy-loaded, e.g. a file on disk,\n * you can define a `loadNodeContent` function for this node and the node\n * content will be lazy loaded when it's needed.\n * @param {string} node.internal.contentDigest the digest for the content\n * of this node. Helps Gatsby avoid doing extra work on data that hasn't\n * changed.\n * @param {string} node.internal.description An optional field. Human\n * readable description of what this node represent / its source. It will\n * be displayed when type conflicts are found, making it easier to find\n * and correct type conflicts.\n * @returns {Promise} The returned Promise resolves when all cascading\n * `onCreateNode` API calls triggered by `createNode` have finished.\n * @example\n * createNode({\n * // Data for the node.\n * field1: `a string`,\n * field2: 10,\n * field3: true,\n * ...arbitraryOtherData,\n *\n * // Required fields.\n * id: `a-node-id`,\n * parent: `the-id-of-the-parent-node`, // or null if it's a source node without a parent\n * children: [],\n * internal: {\n * type: `CoolServiceMarkdownField`,\n * contentDigest: crypto\n * .createHash(`md5`)\n * .update(JSON.stringify(fieldData))\n * .digest(`hex`),\n * mediaType: `text/markdown`, // optional\n * content: JSON.stringify(fieldData), // optional\n * description: `Cool Service: \"Title of entry\"`, // optional\n * }\n * })\n */\nconst createNode = (\n node: any,\n plugin?: Plugin,\n actionOptions?: ActionOptions = {}\n) => {\n if (!_.isObject(node)) {\n return console.log(\n chalk.bold.red(\n `The node passed to the \"createNode\" action creator must be an object`\n )\n )\n }\n\n // Ensure the new node has an internals object.\n if (!node.internal) {\n node.internal = {}\n }\n\n // Ensure the new node has a children array.\n if (!node.array && !_.isArray(node.children)) {\n node.children = []\n }\n\n // Ensure the new node has a parent field\n if (!node.parent) {\n node.parent = null\n }\n\n // Tell user not to set the owner name themself.\n if (node.internal.owner) {\n report.error(JSON.stringify(node, null, 4))\n report.panic(\n chalk.bold.red(\n `The node internal.owner field is set automatically by Gatsby and not by plugins`\n )\n )\n }\n\n const trackParams = {}\n // Add the plugin name to the internal object.\n if (plugin) {\n node.internal.owner = plugin.name\n trackParams[`pluginName`] = `${plugin.name}@${plugin.version}`\n }\n\n trackCli(`CREATE_NODE`, trackParams, { debounce: true })\n\n const result = nodeSchema.validate(node)\n if (result.error) {\n if (!hasErroredBecauseOfNodeValidation.has(result.error.message)) {\n const errorObj = {\n id: `11467`,\n context: {\n validationErrorMessage: result.error.message,\n node,\n },\n }\n\n const possiblyCodeFrame = getNonGatsbyCodeFrame()\n if (possiblyCodeFrame) {\n errorObj.context.codeFrame = possiblyCodeFrame.codeFrame\n errorObj.filePath = possiblyCodeFrame.fileName\n errorObj.location = {\n start: {\n line: possiblyCodeFrame.line,\n column: possiblyCodeFrame.column,\n },\n }\n }\n\n report.error(errorObj)\n hasErroredBecauseOfNodeValidation.add(result.error.message)\n }\n\n return { type: `VALIDATION_ERROR`, error: true }\n }\n\n // Ensure node isn't directly setting fields.\n if (node.fields) {\n throw new Error(\n stripIndent`\n Plugins creating nodes can not set data on the reserved field \"fields\"\n as this is reserved for plugins which wish to extend your nodes.\n\n If your plugin didn't add \"fields\" you're probably seeing this\n error because you're reusing an old node object.\n\n Node:\n\n ${JSON.stringify(node, null, 4)}\n\n Plugin that created the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `\n )\n }\n\n node = sanitizeNode(node)\n\n const oldNode = getNode(node.id)\n\n // Ensure the plugin isn't creating a node type owned by another\n // plugin. Type \"ownership\" is first come first served.\n if (plugin) {\n const pluginName = plugin.name\n\n if (!typeOwners[node.internal.type])\n typeOwners[node.internal.type] = pluginName\n else if (typeOwners[node.internal.type] !== pluginName)\n throw new Error(stripIndent`\n The plugin \"${pluginName}\" created a node of a type owned by another plugin.\n\n The node type \"${node.internal.type}\" is owned by \"${\n typeOwners[node.internal.type]\n }\".\n\n If you copy and pasted code from elsewhere, you'll need to pick a new type name\n for your new node(s).\n\n The node object passed to \"createNode\":\n\n ${JSON.stringify(node, null, 4)}\n\n The plugin creating the node:\n\n ${JSON.stringify(plugin, null, 4)}\n `)\n\n // If the node has been created in the past, check that\n // the current plugin is the same as the previous.\n if (oldNode && oldNode.internal.owner !== pluginName) {\n throw new Error(\n stripIndent`\n Nodes can only be updated by their owner. Node \"${node.id}\" is\n owned by \"${oldNode.internal.owner}\" and another plugin \"${pluginName}\"\n tried to update it.\n\n `\n )\n }\n }\n\n if (actionOptions.parentSpan) {\n actionOptions.parentSpan.setTag(`nodeId`, node.id)\n actionOptions.parentSpan.setTag(`nodeType`, node.id)\n }\n\n let deleteActions\n let updateNodeAction\n // Check if the node has already been processed.\n if (oldNode && !hasNodeChanged(node.id, node.internal.contentDigest)) {\n updateNodeAction = {\n ...actionOptions,\n plugin,\n type: `TOUCH_NODE`,\n payload: node.id,\n }\n } else {\n // Remove any previously created descendant nodes as they're all due\n // to be recreated.\n if (oldNode) {\n const createDeleteAction = node => {\n return {\n ...actionOptions,\n type: `DELETE_NODE`,\n plugin,\n payload: node,\n }\n }\n deleteActions = findChildren(oldNode.children)\n .map(getNode)\n .map(createDeleteAction)\n }\n\n node.internal.counter = getNextNodeCounter()\n\n updateNodeAction = {\n ...actionOptions,\n type: `CREATE_NODE`,\n plugin,\n oldNode,\n payload: node,\n }\n }\n\n if (deleteActions && deleteActions.length) {\n return [...deleteActions, updateNodeAction]\n } else {\n return updateNodeAction\n }\n}\n\nactions.createNode =\n (...args) =>\n dispatch => {\n const actions = createNode(...args)\n\n dispatch(actions)\n const createNodeAction = (\n Array.isArray(actions) ? actions : [actions]\n ).find(action => action.type === `CREATE_NODE`)\n\n if (!createNodeAction) {\n return Promise.resolve(undefined)\n }\n\n const { payload: node, traceId, parentSpan } = createNodeAction\n const maybePromise = apiRunnerNode(`onCreateNode`, {\n node: wrapNode(node),\n traceId,\n parentSpan,\n traceTags: { nodeId: node.id, nodeType: node.internal.type },\n })\n\n if (maybePromise?.then) {\n return maybePromise.then(res =>\n getDataStore()\n .ready()\n .then(() => res)\n )\n } else {\n return getDataStore()\n .ready()\n .then(() => maybePromise)\n }\n }\n\nconst touchNodeDeprecationWarningDisplayedMessages = new Set()\n\n/**\n * \"Touch\" a node. Tells Gatsby a node still exists and shouldn't\n * be garbage collected. Primarily useful for source plugins fetching\n * nodes from a remote system that can return only nodes that have\n * updated. The source plugin then touches all the nodes that haven't\n * updated but still exist so Gatsby knows to keep them.\n * @param {Object} node A node object. See the \"createNode\" action for more information about the node object details.\n * @example\n * touchNode(node)\n */\nactions.touchNode = (node: any, plugin?: Plugin) => {\n if (node && !typeOwners[node.internal.type]) {\n typeOwners[node.internal.type] = node.internal.owner\n }\n\n const nodeId = node?.id\n\n if (!nodeId) {\n // if we don't have a node id, we don't want to dispatch this action\n return []\n }\n\n return {\n type: `TOUCH_NODE`,\n plugin,\n payload: nodeId,\n }\n}\n\ntype CreateNodeInput = {\n node: Object,\n name?: string,\n value: any,\n}\n/**\n * Extend another node. The new node field is placed under the `fields`\n * key on the extended node object.\n *\n * Once a plugin has claimed a field name the field name can't be used by\n * other plugins. Also since nodes are immutable, you can't mutate the node\n * directly. So to extend another node, use this.\n * @param {Object} $0\n * @param {Object} $0.node the target node object\n * @param {string} $0.name the name for the field\n * @param {any} $0.value the value for the field\n * @example\n * createNodeField({\n * node,\n * name: `happiness`,\n * value: `is sweet graphql queries`\n * })\n *\n * // The field value is now accessible at node.fields.happiness\n */\nactions.createNodeField = (\n { node, name, value }: CreateNodeInput,\n plugin: Plugin,\n actionOptions?: ActionOptions\n) => {\n // Ensure required fields are set.\n if (!node.internal.fieldOwners) {\n node.internal.fieldOwners = {}\n }\n if (!node.fields) {\n node.fields = {}\n }\n\n // Normalized name of the field that will be used in schema\n const schemaFieldName = _.includes(name, `___NODE`)\n ? name.split(`___`)[0]\n : name\n\n // Check that this field isn't owned by another plugin.\n const fieldOwner = node.internal.fieldOwners[schemaFieldName]\n if (fieldOwner && fieldOwner !== plugin.name) {\n throw new Error(\n stripIndent`\n A plugin tried to update a node field that it doesn't own:\n\n Node id: ${node.id}\n Plugin: ${plugin.name}\n name: ${name}\n value: ${value}\n `\n )\n }\n\n // Update node\n node.fields[name] = value\n node.internal.fieldOwners[schemaFieldName] = plugin.name\n node = sanitizeNode(node)\n\n return {\n ...actionOptions,\n type: `ADD_FIELD_TO_NODE`,\n plugin,\n payload: node,\n addedField: name,\n }\n}\n\n/**\n * Creates a link between a parent and child node. This is used when you\n * transform content from a node creating a new child node. You need to add\n * this new child node to the `children` array of the parent but since you\n * don't have direct access to the immutable parent node, use this action\n * instead.\n * @param {Object} $0\n * @param {Object} $0.parent the parent node object\n * @param {Object} $0.child the child node object\n * @example\n * createParentChildLink({ parent: parentNode, child: childNode })\n */\nactions.createParentChildLink = (\n { parent, child }: { parent: any, child: any },\n plugin?: Plugin\n) => {\n if (!parent.children.includes(child.id)) {\n parent.children.push(child.id)\n }\n\n return {\n type: `ADD_CHILD_NODE_TO_PARENT_NODE`,\n plugin,\n payload: parent,\n }\n}\n\n/**\n * Merge additional configuration into the current webpack config. A few\n * configurations options will be ignored if set, in order to try prevent accidental breakage.\n * Specifically, any change to `entry`, `output`, `target`, or `resolveLoaders` will be ignored.\n *\n * For full control over the webpack config, use `replaceWebpackConfig()`.\n *\n * @param {Object} config partial webpack config, to be merged into the current one\n */\nactions.setWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {\n if (config.node?.fs === `empty`) {\n report.warn(\n `[deprecated${\n plugin ? ` ` + plugin.name : ``\n }] node.fs is deprecated. Please set \"resolve.fallback.fs = false\".`\n )\n delete config.node.fs\n config.resolve = config.resolve || {}\n config.resolve.fallback = config.resolve.fallback || {}\n config.resolve.fallback.fs = false\n }\n\n return {\n type: `SET_WEBPACK_CONFIG`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Completely replace the webpack config for the current stage. This can be\n * dangerous and break Gatsby if certain configuration options are changed.\n *\n * Generally only useful for cases where you need to handle config merging logic\n * yourself, in which case consider using `webpack-merge`.\n *\n * @param {Object} config complete webpack config\n */\nactions.replaceWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {\n if (config.node?.fs === `empty`) {\n report.warn(\n `[deprecated${\n plugin ? ` ` + plugin.name : ``\n }] node.fs is deprecated. Please set \"resolve.fallback.fs = false\".`\n )\n delete config.node.fs\n config.resolve = config.resolve || {}\n config.resolve.fallback = config.resolve.fallback || {}\n config.resolve.fallback.fs = false\n }\n\n return {\n type: `REPLACE_WEBPACK_CONFIG`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Set top-level Babel options. Plugins and presets will be ignored. Use\n * setBabelPlugin and setBabelPreset for this.\n * @param {Object} config An options object in the shape of a normal babelrc JavaScript object\n * @example\n * setBabelOptions({\n * options: {\n * sourceMaps: `inline`,\n * }\n * })\n */\nactions.setBabelOptions = (options: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!_.isObject(options)) {\n console.log(`${name} must pass an object to \"setBabelOptions\"`)\n console.log(JSON.stringify(options, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n\n if (!_.isObject(options.options)) {\n console.log(`${name} must pass options to \"setBabelOptions\"`)\n console.log(JSON.stringify(options, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n\n return {\n type: `SET_BABEL_OPTIONS`,\n plugin,\n payload: options,\n }\n}\n\n/**\n * Add new plugins or merge options into existing Babel plugins.\n * @param {Object} config A config object describing the Babel plugin to be added.\n * @param {string} config.name The name of the Babel plugin\n * @param {Object} config.options Options to pass to the Babel plugin.\n * @example\n * setBabelPlugin({\n * name: `@emotion/babel-plugin`,\n * options: {\n * sourceMap: true,\n * },\n * })\n */\nactions.setBabelPlugin = (config: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!config.name) {\n console.log(`${name} must set the name of the Babel plugin`)\n console.log(JSON.stringify(config, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n if (!config.options) {\n config.options = {}\n }\n return {\n type: `SET_BABEL_PLUGIN`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * Add new presets or merge options into existing Babel presets.\n * @param {Object} config A config object describing the Babel plugin to be added.\n * @param {string} config.name The name of the Babel preset.\n * @param {Object} config.options Options to pass to the Babel preset.\n * @example\n * setBabelPreset({\n * name: `@babel/preset-react`,\n * options: {\n * pragma: `Glamor.createElement`,\n * },\n * })\n */\nactions.setBabelPreset = (config: Object, plugin?: ?Plugin = null) => {\n // Validate\n let name = `The plugin \"${plugin.name}\"`\n if (plugin.name === `default-site-plugin`) {\n name = `Your site's \"gatsby-node.js\"`\n }\n if (!config.name) {\n console.log(`${name} must set the name of the Babel preset`)\n console.log(JSON.stringify(config, null, 4))\n if (isNotTestEnv) {\n process.exit(1)\n }\n }\n if (!config.options) {\n config.options = {}\n }\n return {\n type: `SET_BABEL_PRESET`,\n plugin,\n payload: config,\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * Create a \"job\". This is a long-running process that is generally\n * started as a side-effect to a GraphQL query.\n * [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) uses this for\n * example.\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * createJob({ id: `write file id: 123`, fileName: `something.jpeg` })\n */\nactions.createJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"createJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `CREATE_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * Create a \"job\". This is a long-running process that is generally\n * started as a side-effect to a GraphQL query.\n * [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) uses this for\n * example.\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with name, inputPaths, outputDir and args\n * @param {string} job.name The name of the job you want to execute\n * @param {string[]} job.inputPaths The inputPaths that are needed to run\n * @param {string} job.outputDir The directory where all files are being saved to\n * @param {Object} job.args The arguments the job needs to execute\n * @returns {Promise<object>} Promise to see if the job is done executing\n * @example\n * createJobV2({ name: `IMAGE_PROCESSING`, inputPaths: [`something.jpeg`], outputDir: `public/static`, args: { width: 100, height: 100 } })\n */\nactions.createJobV2 = (job: JobV2, plugin: Plugin) => (dispatch, getState) => {\n const internalJob = createInternalJob(job, plugin)\n\n const maybeWorkerPromise = maybeSendJobToMainProcess(internalJob)\n if (maybeWorkerPromise) {\n return maybeWorkerPromise\n }\n\n return createJobV2FromInternalJob(internalJob)(dispatch, getState)\n}\n\nactions.addGatsbyImageSourceUrl = (sourceUrl: string) => {\n return {\n type: `PROCESS_GATSBY_IMAGE_SOURCE_URL`,\n payload: { sourceUrl },\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * Set (update) a \"job\". Sometimes on really long running jobs you want\n * to update the job as it continues.\n *\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * setJob({ id: `write file id: 123`, progress: 50 })\n */\nactions.setJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"setJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `SET_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * DEPRECATED. Use createJobV2 instead.\n *\n * End a \"job\".\n *\n * Gatsby doesn't finish its process until all jobs are ended.\n * @param {Object} job A job object with at least an id set\n * @param {id} job.id The id of the job\n * @deprecated Use \"createJobV2\" instead\n * @example\n * endJob({ id: `write file id: 123` })\n */\nactions.endJob = (job: Job, plugin?: ?Plugin = null) => {\n let msg = `Action \"endJob\" is deprecated. Please use \"createJobV2\" instead`\n\n if (plugin?.name) {\n msg = msg + ` (called by ${plugin.name})`\n }\n reportOnce(msg)\n\n return {\n type: `END_JOB`,\n plugin,\n payload: job,\n }\n}\n\n/**\n * Set plugin status. A plugin can use this to save status keys e.g. the last\n * it fetched something. These values are persisted between runs of Gatsby.\n *\n * @param {Object} status An object with arbitrary values set\n * @example\n * setPluginStatus({ lastFetched: Date.now() })\n */\nactions.setPluginStatus = (\n status: { [key: string]: mixed },\n plugin: Plugin\n) => {\n return {\n type: `SET_PLUGIN_STATUS`,\n plugin,\n payload: status,\n }\n}\n\n// Check if path is absolute and add pathPrefix in front if it's not\nconst maybeAddPathPrefix = (path, pathPrefix) => {\n const parsed = url.parse(path)\n const isRelativeProtocol = path.startsWith(`//`)\n return `${\n parsed.protocol != null || isRelativeProtocol ? `` : pathPrefix\n }${path}`\n}\n\n/**\n * Create a redirect from one page to another. Redirects work out of the box with Gatsby Cloud. Read more about\n * [working with redirects on Gatsby Cloud](https://support.gatsbyjs.com/hc/en-us/articles/1500003051241-Working-with-Redirects).\n * If you are hosting somewhere other than Gatsby Cloud, you will need a plugin to integrate the redirect data with\n * your hosting technology e.g. the [Netlify\n * plugin](/plugins/gatsby-plugin-netlify/), or the [Amazon S3\n * plugin](/plugins/gatsby-plugin-s3/). Alternatively, you can use\n * [this plugin](/plugins/gatsby-plugin-meta-redirect/) to generate meta redirect\n * html files for redirecting on any static file host.\n *\n * @param {Object} redirect Redirect data\n * @param {string} redirect.fromPath Any valid URL. Must start with a forward slash\n * @param {boolean} redirect.isPermanent This is a permanent redirect; defaults to temporary\n * @param {string} redirect.toPath URL of a created page (see `createPage`)\n * @param {boolean} redirect.redirectInBrowser Redirects are generally for redirecting legacy URLs to their new configuration on the server. If you can't update your UI for some reason, set `redirectInBrowser` to true and Gatsby will handle redirecting in the client as well. You almost never need this so be sure your use case fits before enabling.\n * @param {boolean} redirect.force (Plugin-specific) Will trigger the redirect even if the `fromPath` matches a piece of content. This is not part of the Gatsby API, but implemented by (some) plugins that configure hosting provider redirects\n * @param {number} redirect.statusCode (Plugin-specific) Manually set the HTTP status code. This allows you to create a rewrite (status code 200) or custom error page (status code 404). Note that this will override the `isPermanent` option which also sets the status code. This is not part of the Gatsby API, but implemented by (some) plugins that configure hosting provider redirects\n * @param {boolean} redirect.ignoreCase (Plugin-specific) Ignore case when looking for redirects\n * @param {Object} redirect.conditions Specify a country or language based redirect\n * @param {(string|string[])} redirect.conditions.country A two-letter country code based on the regional indicator symbol\n * @param {(string|string[])} redirect.conditions.language A two-letter identifier defined by ISO 639-1\n * @example\n * // Generally you create redirects while creating pages.\n * exports.createPages = ({ graphql, actions }) => {\n * const { createRedirect } = actions\n * createRedirect({ fromPath: '/old-url', toPath: '/new-url', isPermanent: true })\n * createRedirect({ fromPath: '/url', toPath: '/zn-CH/url', conditions: { language: 'zn' }})\n * createRedirect({ fromPath: '/url', toPath: '/en/url', conditions: { language: ['ca', 'us'] }})\n * createRedirect({ fromPath: '/url', toPath: '/ca/url', conditions: { country: 'ca' }})\n * createRedirect({ fromPath: '/url', toPath: '/en/url', conditions: { country: ['ca', 'us'] }})\n * createRedirect({ fromPath: '/not_so-pretty_url', toPath: '/pretty/url', statusCode: 200 })\n * // Create pages here\n * }\n */\nactions.createRedirect = ({\n fromPath,\n isPermanent = false,\n redirectInBrowser = false,\n toPath,\n ignoreCase = true,\n ...rest\n}) => {\n let pathPrefix = ``\n if (store.getState().program.prefixPaths) {\n pathPrefix = store.getState().config.pathPrefix\n }\n\n return {\n type: `CREATE_REDIRECT`,\n payload: {\n fromPath: maybeAddPathPrefix(fromPath, pathPrefix),\n isPermanent,\n ignoreCase,\n redirectInBrowser,\n toPath: maybeAddPathPrefix(toPath, pathPrefix),\n ...rest,\n },\n }\n}\n\n/**\n * Create a dependency between a page and data.\n *\n * @param {Object} $0\n * @param {string} $0.path the path to the page\n * @param {string} $0.nodeId A node ID\n * @param {string} $0.connection A connection type\n * @private\n */\nactions.createPageDependency = (\n {\n path,\n nodeId,\n connection,\n }: { path: string, nodeId: string, connection: string },\n plugin: string = ``\n) => {\n console.warn(\n `Calling \"createPageDependency\" directly from actions in deprecated. Use \"createPageDependency\" from \"gatsby/dist/redux/actions/add-page-dependency\".`\n )\n return {\n type: `CREATE_COMPONENT_DEPENDENCY`,\n plugin,\n payload: [\n {\n path,\n nodeId,\n connection,\n },\n ],\n }\n}\n\n/**\n * Record that a page was visited on the server..\n *\n * @param {Object} $0\n * @param {string} $0.id the chunkName for the page component.\n */\nactions.createServerVisitedPage = (chunkName: string) => {\n if (store.getState().visitedPages.get(`server`)?.has(chunkName)) {\n // we already have given chunk tracked, let's not emit `CREATE_SERVER_VISITED_PAGE`\n // action to not cause any additional work\n return []\n }\n\n return {\n type: `CREATE_SERVER_VISITED_PAGE`,\n payload: { componentChunkName: chunkName },\n }\n}\n\n/**\n * Creates an individual node manifest.\n * This is used to tie the unique revision state within a data source at the current point in time to a page generated from the provided node when it's node manifest is processed.\n *\n * @param {Object} manifest Manifest data\n * @param {string} manifest.manifestId An id which ties the unique revision state of this manifest to the unique revision state of a data source.\n * @param {Object} manifest.node The Gatsby node to tie the manifestId to. See the \"createNode\" action for more information about the node object details.\n * @param {string} manifest.updatedAtUTC (optional) The time in which the node was last updated. If this parameter is not included, a manifest is created for every node that gets called. By default, node manifests are created for content updated in the last 30 days. To change this, set a `NODE_MANIFEST_MAX_DAYS_OLD` environment variable.\n * @example\n * unstable_createNodeManifest({\n * manifestId: `post-id-1--updated-53154315`,\n * updatedAtUTC: `2021-07-08T21:52:28.791+01:00`,\n * node: {\n * id: `post-id-1`\n * },\n * })\n */\nactions.unstable_createNodeManifest = (\n { manifestId, node, updatedAtUTC },\n plugin: Plugin\n) => {\n return {\n type: `CREATE_NODE_MANIFEST`,\n payload: {\n manifestId,\n node,\n pluginName: plugin.name,\n updatedAtUTC,\n },\n }\n}\n\n/**\n * Stores request headers for a given domain to be later used when making requests for Image CDN (and potentially other features).\n *\n * @param {Object} $0\n * @param {string} $0.domain The domain to store the headers for.\n * @param {Object} $0.headers The headers to store.\n */\nactions.setRequestHeaders = ({ domain, headers }, plugin: Plugin) => {\n const headersIsObject =\n typeof headers === `object` && headers !== null && !Array.isArray(headers)\n\n const noHeaders = !headersIsObject\n const noDomain = typeof domain !== `string`\n\n if (noHeaders) {\n reporter.warn(\n `Plugin ${plugin.name} called actions.setRequestHeaders with a headers property that isn't an object.`\n )\n }\n\n if (noDomain) {\n reporter.warn(\n `Plugin ${plugin.name} called actions.setRequestHeaders with a domain property that isn't a string.`\n )\n }\n\n if (noDomain || noHeaders) {\n reporter.panic(\n `Plugin ${plugin.name} attempted to set request headers with invalid arguments. See above warnings for more info.`\n )\n\n return null\n }\n\n const baseDomain = url.parse(domain)?.hostname\n\n if (baseDomain) {\n return {\n type: `SET_REQUEST_HEADERS`,\n payload: {\n domain: baseDomain,\n headers,\n },\n }\n } else {\n reporter.panic(\n `Plugin ${plugin.name} attempted to set request headers for a domain that is not a valid URL. (${domain})`\n )\n\n return null\n }\n}\n\nmodule.exports = { actions }\n"],"mappings":";;AAiBA;;AAGA;;AAaA;;AACA;;AACA;;AACA;;AAnCA,MAAMA,QAAQ,GAAGC,OAAO,CAAE,yBAAF,CAAxB;;AACA,MAAMC,KAAK,GAAGD,OAAO,CAAE,OAAF,CAArB;;AACA,MAAME,CAAC,GAAGF,OAAO,CAAE,QAAF,CAAjB;;AACA,MAAM;EAAEG;AAAF,IAAkBH,OAAO,CAAE,aAAF,CAA/B;;AACA,MAAMI,MAAM,GAAGJ,OAAO,CAAE,yBAAF,CAAtB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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMS,UAAU,GAAG,CACjBvB,IADiB,EAEjB1E,MAFiB,EAGjBC,aAA6B,GAAG,EAHf,KAId;EACH,IAAI,CAACxE,CAAC,CAACyK,QAAF,CAAWxB,IAAX,CAAL,EAAuB;IACrB,OAAOyB,OAAO,CAACC,GAAR,CACL5K,KAAK,CAACgJ,IAAN,CAAW6B,GAAX,CACG,sEADH,CADK,CAAP;EAKD,CAPE,CASH;;;EACA,IAAI,CAAC3B,IAAI,CAACC,QAAV,EAAoB;IAClBD,IAAI,CAACC,QAAL,GAAgB,EAAhB;EACD,CAZE,CAcH;;;EACA,IAAI,CAACD,IAAI,CAAC4B,KAAN,IAAe,CAAC7K,CAAC,CAAC0D,OAAF,CAAUuF,IAAI,CAACjG,QAAf,CAApB,EAA8C;IAC5CiG,IAAI,CAACjG,QAAL,GAAgB,EAAhB;EACD,CAjBE,CAmBH;;;EACA,IAAI,CAACiG,IAAI,CAAC6B,MAAV,EAAkB;IAChB7B,IAAI,CAAC6B,MAAL,GAAc,IAAd;EACD,CAtBE,CAwBH;;;EACA,IAAI7B,IAAI,CAACC,QAAL,CAAc6B,KAAlB,EAAyB;IACvB7K,MAAM,CAAC+E,KAAP,CAAaG,IAAI,CAACC,SAAL,CAAe4D,IAAf,EAAqB,IAArB,EAA2B,CAA3B,CAAb;IACA/I,MAAM,CAACyE,KAAP,CACE5E,KAAK,CAACgJ,IAAN,CAAW6B,GAAX,CACG,i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EACnE,MAAMwM,eAAe,GACnB,OAAOD,OAAP,KAAoB,QAApB,IAA+BA,OAAO,KAAK,IAA3C,IAAmD,CAACzE,KAAK,CAAC3I,OAAN,CAAcoN,OAAd,CADtD;EAGA,MAAME,SAAS,GAAG,CAACD,eAAnB;EACA,MAAME,QAAQ,GAAG,OAAOJ,MAAP,KAAmB,QAApC;;EAEA,IAAIG,SAAJ,EAAe;IACbnR,QAAQ,CAAC2F,IAAT,CACG,UAASjB,MAAM,CAACE,IAAK,iFADxB;EAGD;;EAED,IAAIwM,QAAJ,EAAc;IACZpR,QAAQ,CAAC2F,IAAT,CACG,UAASjB,MAAM,CAACE,IAAK,+EADxB;EAGD;;EAED,IAAIwM,QAAQ,IAAID,SAAhB,EAA2B;IACzBnR,QAAQ,CAAC8E,KAAT,CACG,UAASJ,MAAM,CAACE,IAAK,6FADxB;IAIA,OAAO,IAAP;EACD;;EAED,MAAMyM,UAAU,iBAAG5Q,GAAG,CAACkP,KAAJ,CAAUqB,MAAV,CAAH,+CAAG,WAAmBM,QAAtC;;EAEA,IAAID,UAAJ,EAAgB;IACd,OAAO;MACLpN,IAAI,EAAG,qBADF;MAELC,OAAO,EAAE;QACP8M,MAAM,EAAEK,UADD;QAEPJ;MAFO;IAFJ,CAAP;EAOD,CARD,MAQO;IACLjR,QAAQ,CAAC8E,KAAT,CACG,UAASJ,MAAM,CAACE,IAAK,4EAA2EoM,MAAO,GAD1G;IAIA,OAAO,IAAP;EACD;AACF,CA5CD;;AA8CAO,MAAM,CAACC,OAAP,GAAiB;EAAEnP;AAAF,CAAjB"}
@@ -167,6 +167,9 @@ function isFlushEnqueued() {
167
167
  return isFlushPending;
168
168
  }
169
169
 
170
+ let staleNodeManifests = false;
171
+ const maxManifestIdsToLog = 50;
172
+
170
173
  async function flush(parentSpan) {
171
174
  var _program$_;
172
175
 
@@ -186,7 +189,8 @@ async function flush(parentSpan) {
186
189
  staticQueriesByTemplate,
187
190
  queries,
188
191
  slices,
189
- slicesByTemplate
192
+ slicesByTemplate,
193
+ nodeManifests
190
194
  } = _redux.store.getState();
191
195
 
192
196
  const isBuild = (program === null || program === void 0 ? void 0 : (_program$_ = program._) === null || _program$_ === void 0 ? void 0 : _program$_[0]) !== `develop`;
@@ -202,6 +206,14 @@ async function flush(parentSpan) {
202
206
  // We use this manifestId to determine if the page data is up to date when routing. Here we create a map of "pagePath": "manifestId" while processing and writing node manifest files.
203
207
  // We only do this when there are pending page-data writes because otherwise we could flush pending createNodeManifest calls before page-data.json files are written. Which means those page-data files wouldn't have the corresponding manifest id's written to them.
204
208
  nodeManifestPagePathMap = await (0, _nodeManifest.processNodeManifests)();
209
+ } else if (nodeManifests.length > 0 && staleNodeManifests) {
210
+ staleNodeManifests = false;
211
+
212
+ _reporter.default.warn(`[gatsby] node manifests were created but no page-data.json files were written, so manifest ID's were not added to page-data.json files. This may be a bug or it may be due to a source plugin creating a node manifest for a node that did not change. Node manifest IDs: ${nodeManifests.map(n => n.manifestId).slice(0, maxManifestIdsToLog).join(`,`)}${nodeManifests.length > maxManifestIdsToLog ? ` There were ${nodeManifests.length - maxManifestIdsToLog} additional ID's that were not logged due to output length.` : ``}`);
213
+
214
+ nodeManifestPagePathMap = await (0, _nodeManifest.processNodeManifests)();
215
+ } else if (nodeManifests.length > 0) {
216
+ staleNodeManifests = true;
205
217
  }
206
218
 
207
219
  if (pagePaths.size > 0 || sliceNames.size > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"page-data.js","names":["readPageData","publicDir","pagePath","filePath","generatePageDataPath","rawPageData","fs","readFile","JSON","parse","removePageData","existsSync","remove","Promise","resolve","pageDataExists","lmdbPageQueryResultsCache","getLMDBPageQueryResultsCache","GatsbyCacheLmdbImpl","require","default","name","encoding","init","savePageQueryResultsPromise","waitUntilPageQueryResultsAreStored","savePageQueryResult","stringifiedResult","set","readPageQueryResult","get","Error","writePageData","pageData","slicesUsedByTemplates","slices","result","path","outputFilePath","body","constructPageDataString","pageDataSize","Buffer","byteLength","store","dispatch","type","payload","size","pageDataHash","createContentDigest","ensureFileContent","writeSliceData","componentChunkName","staticQueryHashes","toString","join","sliceData","stringify","sliceDataSize","sliceName","sliceDataHash","readSliceData","isFlushPending","isFlushing","isFlushEnqueued","flush","parentSpan","pendingPageDataWrites","pages","program","staticQueriesByTemplate","queries","slicesByTemplate","getState","isBuild","_","pagePaths","sliceNames","writePageDataActivity","nodeManifestPagePathMap","processNodeManifests","reporter","createProgress","id","start","flushQueue","fastq","task","cb","page","shouldClearPendingWrite","manifestId","process","env","GATSBY_QUERY_ON_DEMAND","query","trackedQueries","hasFlag","dirty","FLAG_DIRTY_NEW_PAGE","setImmediate","getPageMode","componentPath","directory","websocketManager","emitPageData","e","panicOnBuild","tick","slice","emitSliceData","push","idle","drain","end","enqueueFlush","isWebpackStatusPending","handleStalePageData","pathExists","activity","activityTimer","pageDataFilesFromPreviousBuilds","reject","results","Set","stream","fsWalkStream","on","data","add","expectedPageDataFiles","forEach","deletionPromises","pageDataFilePath","has","all"],"sources":["../../src/utils/page-data.ts"],"sourcesContent":["import { walkStream as fsWalkStream, Entry } from \"@nodelib/fs.walk\"\nimport fs from \"fs-extra\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport fastq from \"fastq\"\nimport path from \"path\"\nimport { createContentDigest, generatePageDataPath } from \"gatsby-core-utils\"\nimport { websocketManager } from \"./websocket-manager\"\nimport { isWebpackStatusPending } from \"./webpack-status\"\nimport { store } from \"../redux\"\nimport type { IGatsbySlice, IGatsbyState } from \"../redux/types\"\nimport { hasFlag, FLAG_DIRTY_NEW_PAGE } from \"../redux/reducers/queries\"\nimport type GatsbyCacheLmdb from \"./cache-lmdb\"\nimport {\n constructPageDataString,\n reverseFixedPagePath,\n IPageData,\n IPageDataInput,\n} from \"./page-data-helpers\"\nimport { Span } from \"opentracing\"\n\nexport { reverseFixedPagePath }\nimport { processNodeManifests } from \"../utils/node-manifest\"\nimport { IExecutionResult } from \"../query/types\"\nimport { getPageMode } from \"./page-mode\"\nimport { ICollectedSlices } from \"./babel/find-slices\"\nimport { ensureFileContent } from \"./ensure-file-content\"\n\nexport interface IPageDataWithQueryResult extends IPageData {\n result: IExecutionResult\n}\n\nexport interface ISliceData {\n componentChunkName: string\n result: IExecutionResult\n staticQueryHashes: Array<string>\n}\n\nexport async function readPageData(\n publicDir: string,\n pagePath: string\n): Promise<IPageDataWithQueryResult> {\n const filePath = generatePageDataPath(publicDir, pagePath)\n const rawPageData = await fs.readFile(filePath, `utf-8`)\n return JSON.parse(rawPageData)\n}\n\nexport async function removePageData(\n publicDir: string,\n pagePath: string\n): Promise<void> {\n const filePath = generatePageDataPath(publicDir, pagePath)\n\n if (fs.existsSync(filePath)) {\n return await fs.remove(filePath)\n }\n\n return Promise.resolve()\n}\n\nexport function pageDataExists(publicDir: string, pagePath: string): boolean {\n return fs.existsSync(generatePageDataPath(publicDir, pagePath))\n}\n\nlet lmdbPageQueryResultsCache: GatsbyCacheLmdb\nfunction getLMDBPageQueryResultsCache(): GatsbyCacheLmdb {\n if (!lmdbPageQueryResultsCache) {\n const GatsbyCacheLmdbImpl = require(`./cache-lmdb`).default\n lmdbPageQueryResultsCache = new GatsbyCacheLmdbImpl({\n name: `internal-tmp-query-results`,\n encoding: `string`,\n }).init()\n }\n return lmdbPageQueryResultsCache\n}\n\nlet savePageQueryResultsPromise = Promise.resolve()\n\nexport function waitUntilPageQueryResultsAreStored(): Promise<void> {\n return savePageQueryResultsPromise\n}\n\nexport async function savePageQueryResult(\n pagePath: string,\n stringifiedResult: string\n): Promise<void> {\n savePageQueryResultsPromise = getLMDBPageQueryResultsCache().set(\n pagePath,\n stringifiedResult\n ) as Promise<void>\n}\n\nexport async function readPageQueryResult(pagePath: string): Promise<string> {\n const stringifiedResult = await getLMDBPageQueryResultsCache().get(pagePath)\n if (typeof stringifiedResult === `string`) {\n return stringifiedResult\n }\n throw new Error(`Couldn't find temp query result for \"${pagePath}\".`)\n}\n\nexport async function writePageData(\n publicDir: string,\n pageData: IPageDataInput,\n slicesUsedByTemplates: Map<string, ICollectedSlices>,\n slices: IGatsbyState[\"slices\"]\n): Promise<string> {\n const result = await readPageQueryResult(pageData.path)\n\n const outputFilePath = generatePageDataPath(publicDir, pageData.path)\n\n const body = constructPageDataString(\n pageData,\n result,\n slicesUsedByTemplates,\n slices\n )\n\n // transform asset size to kB (from bytes) to fit 64 bit to numbers\n const pageDataSize = Buffer.byteLength(body) / 1000\n\n store.dispatch({\n type: `ADD_PAGE_DATA_STATS`,\n payload: {\n pagePath: pageData.path,\n filePath: outputFilePath,\n size: pageDataSize,\n pageDataHash: createContentDigest(body),\n },\n })\n\n await ensureFileContent(outputFilePath, body)\n return body\n}\n\nexport async function writeSliceData(\n publicDir: string,\n { componentChunkName, name }: IGatsbySlice,\n staticQueryHashes: Array<string>\n): Promise<string> {\n const result = JSON.parse(\n (await readPageQueryResult(`slice--${name}`)).toString()\n )\n\n const outputFilePath = path.join(publicDir, `slice-data`, `${name}.json`)\n\n const sliceData: ISliceData = {\n componentChunkName,\n result,\n staticQueryHashes,\n }\n\n const body = JSON.stringify(sliceData)\n\n const sliceDataSize = Buffer.byteLength(body) / 1000\n\n store.dispatch({\n type: `ADD_SLICE_DATA_STATS`,\n payload: {\n sliceName: name,\n filePath: outputFilePath,\n size: sliceDataSize,\n sliceDataHash: createContentDigest(body),\n },\n })\n\n await ensureFileContent(outputFilePath, body)\n return body\n}\n\nexport async function readSliceData(\n publicDir: string,\n sliceName: string\n): Promise<IPageDataWithQueryResult> {\n const filePath = path.join(publicDir, `slice-data`, `${sliceName}.json`)\n const rawPageData = await fs.readFile(filePath, `utf-8`)\n return JSON.parse(rawPageData)\n}\n\nlet isFlushPending = false\nlet isFlushing = false\n\nexport function isFlushEnqueued(): boolean {\n return isFlushPending\n}\n\ntype IDataTask =\n | {\n type: \"page\"\n pagePath: string\n }\n | {\n type: \"slice\"\n sliceName: string\n }\n\nexport async function flush(parentSpan?: Span): Promise<void> {\n if (isFlushing) {\n // We're already in the middle of a flush\n return\n }\n await waitUntilPageQueryResultsAreStored()\n isFlushPending = false\n isFlushing = true\n const {\n pendingPageDataWrites,\n pages,\n program,\n staticQueriesByTemplate,\n queries,\n slices,\n slicesByTemplate,\n } = store.getState()\n const isBuild = program?._?.[0] !== `develop`\n\n const { pagePaths, sliceNames } = pendingPageDataWrites\n let writePageDataActivity\n\n let nodeManifestPagePathMap\n\n if (pagePaths.size > 0) {\n // we process node manifests in this location because we need to add the manifestId to the page data.\n // We use this manifestId to determine if the page data is up to date when routing. Here we create a map of \"pagePath\": \"manifestId\" while processing and writing node manifest files.\n // We only do this when there are pending page-data writes because otherwise we could flush pending createNodeManifest calls before page-data.json files are written. Which means those page-data files wouldn't have the corresponding manifest id's written to them.\n nodeManifestPagePathMap = await processNodeManifests()\n }\n\n if (pagePaths.size > 0 || sliceNames.size > 0) {\n writePageDataActivity = reporter.createProgress(\n `Writing page-data.json and slice-data.json files to public directory`,\n pagePaths.size + sliceNames.size,\n 0,\n { id: `write-page-data-public-directory`, parentSpan }\n )\n writePageDataActivity.start()\n }\n\n const flushQueue = fastq<void, IDataTask, boolean>(async (task, cb) => {\n if (task.type === `page`) {\n const { pagePath } = task\n const page = pages.get(pagePath)\n\n let shouldClearPendingWrite = true\n\n // It's a gloomy day in Bombay, let me tell you a short story...\n // Once upon a time, writing page-data.json files were atomic\n // After this change (#24808), they are not and this means that\n // between adding a pending write for a page and actually flushing\n // them, a page might not exist anymore щ(゚Д゚щ)\n // This is why we need this check\n if (page) {\n if (page.path && nodeManifestPagePathMap) {\n page.manifestId = nodeManifestPagePathMap.get(page.path)\n }\n\n if (!isBuild && process.env.GATSBY_QUERY_ON_DEMAND) {\n // check if already did run query for this page\n // with query-on-demand we might have pending page-data write due to\n // changes in static queries assigned to page template, but we might not\n // have query result for it\n const query = queries.trackedQueries.get(page.path)\n if (!query) {\n // this should not happen ever\n throw new Error(\n `We have a page, but we don't have registered query for it (???)`\n )\n }\n\n if (hasFlag(query.dirty, FLAG_DIRTY_NEW_PAGE)) {\n // query results are not written yet\n setImmediate(() => cb(null, true))\n return\n }\n }\n\n // In develop we rely on QUERY_ON_DEMAND so we just go through\n // In build we only build these page-json for SSG pages\n if (!isBuild || (isBuild && getPageMode(page) === `SSG`)) {\n const staticQueryHashes =\n staticQueriesByTemplate.get(page.componentPath) || []\n\n try {\n const result = await writePageData(\n path.join(program.directory, `public`),\n {\n ...page,\n staticQueryHashes,\n },\n slicesByTemplate,\n slices\n )\n\n if (!isBuild) {\n websocketManager.emitPageData({\n id: pagePath,\n result: JSON.parse(result) as IPageDataWithQueryResult,\n })\n }\n } catch (e) {\n shouldClearPendingWrite = false\n reporter.panicOnBuild(\n `Failed to write page-data for \"\"${page.path}`,\n e\n )\n }\n writePageDataActivity.tick()\n }\n }\n\n if (shouldClearPendingWrite) {\n store.dispatch({\n type: `CLEAR_PENDING_PAGE_DATA_WRITE`,\n payload: {\n page: pagePath,\n },\n })\n }\n } else if (task.type === `slice`) {\n const { sliceName } = task\n const slice = slices.get(sliceName)\n if (slice) {\n const staticQueryHashes =\n staticQueriesByTemplate.get(slice.componentPath) || []\n\n const result = await writeSliceData(\n path.join(program.directory, `public`),\n slice,\n staticQueryHashes\n )\n\n writePageDataActivity.tick()\n\n if (!isBuild) {\n websocketManager.emitSliceData({\n id: sliceName,\n result: JSON.parse(result) as IPageDataWithQueryResult,\n })\n }\n }\n\n store.dispatch({\n type: `CLEAR_PENDING_SLICE_DATA_WRITE`,\n payload: {\n name: sliceName,\n },\n })\n }\n\n // `setImmediate` below is a workaround against stack overflow\n // occurring when there are many non-SSG pages\n setImmediate(() => cb(null, true))\n return\n }, 25)\n\n for (const pagePath of pagePaths) {\n flushQueue.push({ type: `page`, pagePath }, () => {})\n }\n for (const sliceName of sliceNames) {\n flushQueue.push({ type: `slice`, sliceName }, () => {})\n }\n\n if (!flushQueue.idle()) {\n await new Promise(resolve => {\n flushQueue.drain = resolve as () => unknown\n })\n }\n if (writePageDataActivity) {\n writePageDataActivity.end()\n }\n\n isFlushing = false\n\n return\n}\n\nexport function enqueueFlush(parentSpan?: Span): void {\n if (isWebpackStatusPending()) {\n isFlushPending = true\n } else {\n flush(parentSpan)\n }\n}\n\nexport async function handleStalePageData(parentSpan: Span): Promise<void> {\n if (!(await fs.pathExists(`public/page-data`))) {\n return\n }\n\n // public directory might have stale page-data files from previous builds\n // we get the list of those and compare against expected page-data files\n // and remove ones that shouldn't be there anymore\n\n const activity = reporter.activityTimer(`Cleaning up stale page-data`, {\n parentSpan,\n })\n activity.start()\n\n const pageDataFilesFromPreviousBuilds = await new Promise<Set<string>>(\n (resolve, reject) => {\n const results = new Set<string>()\n\n const stream = fsWalkStream(`public/page-data`)\n\n stream.on(`data`, (data: Entry) => {\n if (data.name === `page-data.json`) {\n results.add(data.path)\n }\n })\n\n stream.on(`error`, e => {\n reject(e)\n })\n\n stream.on(`end`, () => resolve(results))\n }\n )\n\n const expectedPageDataFiles = new Set<string>()\n store.getState().pages.forEach(page => {\n expectedPageDataFiles.add(generatePageDataPath(`public`, page.path))\n })\n\n const deletionPromises: Array<Promise<void>> = []\n pageDataFilesFromPreviousBuilds.forEach(pageDataFilePath => {\n if (!expectedPageDataFiles.has(pageDataFilePath)) {\n deletionPromises.push(fs.remove(pageDataFilePath))\n }\n })\n\n await Promise.all(deletionPromises)\n\n activity.end()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AASA;;AAEA;;AAEA;;AAYO,eAAeA,YAAf,CACLC,SADK,EAELC,QAFK,EAG8B;EACnC,MAAMC,QAAQ,GAAG,IAAAC,qCAAA,EAAqBH,SAArB,EAAgCC,QAAhC,CAAjB;EACA,MAAMG,WAAW,GAAG,MAAMC,gBAAA,CAAGC,QAAH,CAAYJ,QAAZ,EAAuB,OAAvB,CAA1B;EACA,OAAOK,IAAI,CAACC,KAAL,CAAWJ,WAAX,CAAP;AACD;;AAEM,eAAeK,cA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F,CAJD;IAMAyF,MAAM,CAACE,EAAP,CAAW,OAAX,EAAmBrB,CAAC,IAAI;MACtBgB,MAAM,CAAChB,CAAD,CAAN;IACD,CAFD;IAIAmB,MAAM,CAACE,EAAP,CAAW,KAAX,EAAiB,MAAMlH,OAAO,CAAC8G,OAAD,CAA9B;EACD,CAjB2C,CAA9C;EAoBA,MAAMO,qBAAqB,GAAG,IAAIN,GAAJ,EAA9B;;EACAjF,YAAA,CAAM8B,QAAN,GAAiBL,KAAjB,CAAuB+D,OAAvB,CAA+B1C,IAAI,IAAI;IACrCyC,qBAAqB,CAACD,GAAtB,CAA0B,IAAA9H,qCAAA,EAAsB,QAAtB,EAA+BsF,IAAI,CAACrD,IAApC,CAA1B;EACD,CAFD;;EAIA,MAAMgG,gBAAsC,GAAG,EAA/C;EACAX,+BAA+B,CAACU,OAAhC,CAAwCE,gBAAgB,IAAI;IAC1D,IAAI,CAACH,qBAAqB,CAACI,GAAtB,CAA0BD,gBAA1B,CAAL,EAAkD;MAChDD,gBAAgB,CAACrB,IAAjB,CAAsB1G,gBAAA,CAAGM,MAAH,CAAU0H,gBAAV,CAAtB;IACD;EACF,CAJD;EAMA,MAAMzH,OAAO,CAAC2H,GAAR,CAAYH,gBAAZ,CAAN;EAEAb,QAAQ,CAACL,GAAT;AACD"}
1
+ {"version":3,"file":"page-data.js","names":["readPageData","publicDir","pagePath","filePath","generatePageDataPath","rawPageData","fs","readFile","JSON","parse","removePageData","existsSync","remove","Promise","resolve","pageDataExists","lmdbPageQueryResultsCache","getLMDBPageQueryResultsCache","GatsbyCacheLmdbImpl","require","default","name","encoding","init","savePageQueryResultsPromise","waitUntilPageQueryResultsAreStored","savePageQueryResult","stringifiedResult","set","readPageQueryResult","get","Error","writePageData","pageData","slicesUsedByTemplates","slices","result","path","outputFilePath","body","constructPageDataString","pageDataSize","Buffer","byteLength","store","dispatch","type","payload","size","pageDataHash","createContentDigest","ensureFileContent","writeSliceData","componentChunkName","staticQueryHashes","toString","join","sliceData","stringify","sliceDataSize","sliceName","sliceDataHash","readSliceData","isFlushPending","isFlushing","isFlushEnqueued","staleNodeManifests","maxManifestIdsToLog","flush","parentSpan","pendingPageDataWrites","pages","program","staticQueriesByTemplate","queries","slicesByTemplate","nodeManifests","getState","isBuild","_","pagePaths","sliceNames","writePageDataActivity","nodeManifestPagePathMap","processNodeManifests","length","reporter","warn","map","n","manifestId","slice","createProgress","id","start","flushQueue","fastq","task","cb","page","shouldClearPendingWrite","process","env","GATSBY_QUERY_ON_DEMAND","query","trackedQueries","hasFlag","dirty","FLAG_DIRTY_NEW_PAGE","setImmediate","getPageMode","componentPath","directory","websocketManager","emitPageData","e","panicOnBuild","tick","emitSliceData","push","idle","drain","end","enqueueFlush","isWebpackStatusPending","handleStalePageData","pathExists","activity","activityTimer","pageDataFilesFromPreviousBuilds","reject","results","Set","stream","fsWalkStream","on","data","add","expectedPageDataFiles","forEach","deletionPromises","pageDataFilePath","has","all"],"sources":["../../src/utils/page-data.ts"],"sourcesContent":["import { walkStream as fsWalkStream, Entry } from \"@nodelib/fs.walk\"\nimport fs from \"fs-extra\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport fastq from \"fastq\"\nimport path from \"path\"\nimport { createContentDigest, generatePageDataPath } from \"gatsby-core-utils\"\nimport { websocketManager } from \"./websocket-manager\"\nimport { isWebpackStatusPending } from \"./webpack-status\"\nimport { store } from \"../redux\"\nimport type { IGatsbySlice, IGatsbyState } from \"../redux/types\"\nimport { hasFlag, FLAG_DIRTY_NEW_PAGE } from \"../redux/reducers/queries\"\nimport type GatsbyCacheLmdb from \"./cache-lmdb\"\nimport {\n constructPageDataString,\n reverseFixedPagePath,\n IPageData,\n IPageDataInput,\n} from \"./page-data-helpers\"\nimport { Span } from \"opentracing\"\n\nexport { reverseFixedPagePath }\nimport { processNodeManifests } from \"../utils/node-manifest\"\nimport { IExecutionResult } from \"../query/types\"\nimport { getPageMode } from \"./page-mode\"\nimport { ICollectedSlices } from \"./babel/find-slices\"\nimport { ensureFileContent } from \"./ensure-file-content\"\n\nexport interface IPageDataWithQueryResult extends IPageData {\n result: IExecutionResult\n}\n\nexport interface ISliceData {\n componentChunkName: string\n result: IExecutionResult\n staticQueryHashes: Array<string>\n}\n\nexport async function readPageData(\n publicDir: string,\n pagePath: string\n): Promise<IPageDataWithQueryResult> {\n const filePath = generatePageDataPath(publicDir, pagePath)\n const rawPageData = await fs.readFile(filePath, `utf-8`)\n return JSON.parse(rawPageData)\n}\n\nexport async function removePageData(\n publicDir: string,\n pagePath: string\n): Promise<void> {\n const filePath = generatePageDataPath(publicDir, pagePath)\n\n if (fs.existsSync(filePath)) {\n return await fs.remove(filePath)\n }\n\n return Promise.resolve()\n}\n\nexport function pageDataExists(publicDir: string, pagePath: string): boolean {\n return fs.existsSync(generatePageDataPath(publicDir, pagePath))\n}\n\nlet lmdbPageQueryResultsCache: GatsbyCacheLmdb\nfunction getLMDBPageQueryResultsCache(): GatsbyCacheLmdb {\n if (!lmdbPageQueryResultsCache) {\n const GatsbyCacheLmdbImpl = require(`./cache-lmdb`).default\n lmdbPageQueryResultsCache = new GatsbyCacheLmdbImpl({\n name: `internal-tmp-query-results`,\n encoding: `string`,\n }).init()\n }\n return lmdbPageQueryResultsCache\n}\n\nlet savePageQueryResultsPromise = Promise.resolve()\n\nexport function waitUntilPageQueryResultsAreStored(): Promise<void> {\n return savePageQueryResultsPromise\n}\n\nexport async function savePageQueryResult(\n pagePath: string,\n stringifiedResult: string\n): Promise<void> {\n savePageQueryResultsPromise = getLMDBPageQueryResultsCache().set(\n pagePath,\n stringifiedResult\n ) as Promise<void>\n}\n\nexport async function readPageQueryResult(pagePath: string): Promise<string> {\n const stringifiedResult = await getLMDBPageQueryResultsCache().get(pagePath)\n if (typeof stringifiedResult === `string`) {\n return stringifiedResult\n }\n throw new Error(`Couldn't find temp query result for \"${pagePath}\".`)\n}\n\nexport async function writePageData(\n publicDir: string,\n pageData: IPageDataInput,\n slicesUsedByTemplates: Map<string, ICollectedSlices>,\n slices: IGatsbyState[\"slices\"]\n): Promise<string> {\n const result = await readPageQueryResult(pageData.path)\n\n const outputFilePath = generatePageDataPath(publicDir, pageData.path)\n\n const body = constructPageDataString(\n pageData,\n result,\n slicesUsedByTemplates,\n slices\n )\n\n // transform asset size to kB (from bytes) to fit 64 bit to numbers\n const pageDataSize = Buffer.byteLength(body) / 1000\n\n store.dispatch({\n type: `ADD_PAGE_DATA_STATS`,\n payload: {\n pagePath: pageData.path,\n filePath: outputFilePath,\n size: pageDataSize,\n pageDataHash: createContentDigest(body),\n },\n })\n\n await ensureFileContent(outputFilePath, body)\n return body\n}\n\nexport async function writeSliceData(\n publicDir: string,\n { componentChunkName, name }: IGatsbySlice,\n staticQueryHashes: Array<string>\n): Promise<string> {\n const result = JSON.parse(\n (await readPageQueryResult(`slice--${name}`)).toString()\n )\n\n const outputFilePath = path.join(publicDir, `slice-data`, `${name}.json`)\n\n const sliceData: ISliceData = {\n componentChunkName,\n result,\n staticQueryHashes,\n }\n\n const body = JSON.stringify(sliceData)\n\n const sliceDataSize = Buffer.byteLength(body) / 1000\n\n store.dispatch({\n type: `ADD_SLICE_DATA_STATS`,\n payload: {\n sliceName: name,\n filePath: outputFilePath,\n size: sliceDataSize,\n sliceDataHash: createContentDigest(body),\n },\n })\n\n await ensureFileContent(outputFilePath, body)\n return body\n}\n\nexport async function readSliceData(\n publicDir: string,\n sliceName: string\n): Promise<IPageDataWithQueryResult> {\n const filePath = path.join(publicDir, `slice-data`, `${sliceName}.json`)\n const rawPageData = await fs.readFile(filePath, `utf-8`)\n return JSON.parse(rawPageData)\n}\n\nlet isFlushPending = false\nlet isFlushing = false\n\nexport function isFlushEnqueued(): boolean {\n return isFlushPending\n}\n\nlet staleNodeManifests = false\nconst maxManifestIdsToLog = 50\n\ntype IDataTask =\n | {\n type: \"page\"\n pagePath: string\n }\n | {\n type: \"slice\"\n sliceName: string\n }\n\nexport async function flush(parentSpan?: Span): Promise<void> {\n if (isFlushing) {\n // We're already in the middle of a flush\n return\n }\n await waitUntilPageQueryResultsAreStored()\n isFlushPending = false\n isFlushing = true\n const {\n pendingPageDataWrites,\n pages,\n program,\n staticQueriesByTemplate,\n queries,\n slices,\n slicesByTemplate,\n nodeManifests,\n } = store.getState()\n const isBuild = program?._?.[0] !== `develop`\n\n const { pagePaths, sliceNames } = pendingPageDataWrites\n let writePageDataActivity\n\n let nodeManifestPagePathMap\n\n if (pagePaths.size > 0) {\n // we process node manifests in this location because we need to add the manifestId to the page data.\n // We use this manifestId to determine if the page data is up to date when routing. Here we create a map of \"pagePath\": \"manifestId\" while processing and writing node manifest files.\n // We only do this when there are pending page-data writes because otherwise we could flush pending createNodeManifest calls before page-data.json files are written. Which means those page-data files wouldn't have the corresponding manifest id's written to them.\n nodeManifestPagePathMap = await processNodeManifests()\n } else if (nodeManifests.length > 0 && staleNodeManifests) {\n staleNodeManifests = false\n\n reporter.warn(\n `[gatsby] node manifests were created but no page-data.json files were written, so manifest ID's were not added to page-data.json files. This may be a bug or it may be due to a source plugin creating a node manifest for a node that did not change. Node manifest IDs: ${nodeManifests\n .map(n => n.manifestId)\n .slice(0, maxManifestIdsToLog)\n .join(`,`)}${\n nodeManifests.length > maxManifestIdsToLog\n ? ` There were ${\n nodeManifests.length - maxManifestIdsToLog\n } additional ID's that were not logged due to output length.`\n : ``\n }`\n )\n\n nodeManifestPagePathMap = await processNodeManifests()\n } else if (nodeManifests.length > 0) {\n staleNodeManifests = true\n }\n\n if (pagePaths.size > 0 || sliceNames.size > 0) {\n writePageDataActivity = reporter.createProgress(\n `Writing page-data.json and slice-data.json files to public directory`,\n pagePaths.size + sliceNames.size,\n 0,\n { id: `write-page-data-public-directory`, parentSpan }\n )\n writePageDataActivity.start()\n }\n\n const flushQueue = fastq<void, IDataTask, boolean>(async (task, cb) => {\n if (task.type === `page`) {\n const { pagePath } = task\n const page = pages.get(pagePath)\n\n let shouldClearPendingWrite = true\n\n // It's a gloomy day in Bombay, let me tell you a short story...\n // Once upon a time, writing page-data.json files were atomic\n // After this change (#24808), they are not and this means that\n // between adding a pending write for a page and actually flushing\n // them, a page might not exist anymore щ(゚Д゚щ)\n // This is why we need this check\n if (page) {\n if (page.path && nodeManifestPagePathMap) {\n page.manifestId = nodeManifestPagePathMap.get(page.path)\n }\n\n if (!isBuild && process.env.GATSBY_QUERY_ON_DEMAND) {\n // check if already did run query for this page\n // with query-on-demand we might have pending page-data write due to\n // changes in static queries assigned to page template, but we might not\n // have query result for it\n const query = queries.trackedQueries.get(page.path)\n if (!query) {\n // this should not happen ever\n throw new Error(\n `We have a page, but we don't have registered query for it (???)`\n )\n }\n\n if (hasFlag(query.dirty, FLAG_DIRTY_NEW_PAGE)) {\n // query results are not written yet\n setImmediate(() => cb(null, true))\n return\n }\n }\n\n // In develop we rely on QUERY_ON_DEMAND so we just go through\n // In build we only build these page-json for SSG pages\n if (!isBuild || (isBuild && getPageMode(page) === `SSG`)) {\n const staticQueryHashes =\n staticQueriesByTemplate.get(page.componentPath) || []\n\n try {\n const result = await writePageData(\n path.join(program.directory, `public`),\n {\n ...page,\n staticQueryHashes,\n },\n slicesByTemplate,\n slices\n )\n\n if (!isBuild) {\n websocketManager.emitPageData({\n id: pagePath,\n result: JSON.parse(result) as IPageDataWithQueryResult,\n })\n }\n } catch (e) {\n shouldClearPendingWrite = false\n reporter.panicOnBuild(\n `Failed to write page-data for \"\"${page.path}`,\n e\n )\n }\n writePageDataActivity.tick()\n }\n }\n\n if (shouldClearPendingWrite) {\n store.dispatch({\n type: `CLEAR_PENDING_PAGE_DATA_WRITE`,\n payload: {\n page: pagePath,\n },\n })\n }\n } else if (task.type === `slice`) {\n const { sliceName } = task\n const slice = slices.get(sliceName)\n if (slice) {\n const staticQueryHashes =\n staticQueriesByTemplate.get(slice.componentPath) || []\n\n const result = await writeSliceData(\n path.join(program.directory, `public`),\n slice,\n staticQueryHashes\n )\n\n writePageDataActivity.tick()\n\n if (!isBuild) {\n websocketManager.emitSliceData({\n id: sliceName,\n result: JSON.parse(result) as IPageDataWithQueryResult,\n })\n }\n }\n\n store.dispatch({\n type: `CLEAR_PENDING_SLICE_DATA_WRITE`,\n payload: {\n name: sliceName,\n },\n })\n }\n\n // `setImmediate` below is a workaround against stack overflow\n // occurring when there are many non-SSG pages\n setImmediate(() => cb(null, true))\n return\n }, 25)\n\n for (const pagePath of pagePaths) {\n flushQueue.push({ type: `page`, pagePath }, () => {})\n }\n for (const sliceName of sliceNames) {\n flushQueue.push({ type: `slice`, sliceName }, () => {})\n }\n\n if (!flushQueue.idle()) {\n await new Promise(resolve => {\n flushQueue.drain = resolve as () => unknown\n })\n }\n if (writePageDataActivity) {\n writePageDataActivity.end()\n }\n\n isFlushing = false\n\n return\n}\n\nexport function enqueueFlush(parentSpan?: Span): void {\n if (isWebpackStatusPending()) {\n isFlushPending = true\n } else {\n flush(parentSpan)\n }\n}\n\nexport async function handleStalePageData(parentSpan: Span): Promise<void> {\n if (!(await fs.pathExists(`public/page-data`))) {\n return\n }\n\n // public directory might have stale page-data files from previous builds\n // we get the list of those and compare against expected page-data files\n // and remove ones that shouldn't be there anymore\n\n const activity = reporter.activityTimer(`Cleaning up stale page-data`, {\n parentSpan,\n })\n activity.start()\n\n const pageDataFilesFromPreviousBuilds = await new Promise<Set<string>>(\n (resolve, reject) => {\n const results = new Set<string>()\n\n const stream = fsWalkStream(`public/page-data`)\n\n stream.on(`data`, (data: Entry) => {\n if (data.name === `page-data.json`) {\n results.add(data.path)\n }\n })\n\n stream.on(`error`, e => {\n reject(e)\n })\n\n stream.on(`end`, () => resolve(results))\n }\n )\n\n const expectedPageDataFiles = new Set<string>()\n store.getState().pages.forEach(page => {\n expectedPageDataFiles.add(generatePageDataPath(`public`, page.path))\n })\n\n const deletionPromises: Array<Promise<void>> = []\n pageDataFilesFromPreviousBuilds.forEach(pageDataFilePath => {\n if (!expectedPageDataFiles.has(pageDataFilePath)) {\n deletionPromises.push(fs.remove(pageDataFilePath))\n }\n })\n\n await Promise.all(deletionPromises)\n\n activity.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OAAO,CAACqH,OAAD,CAA9B;EACD,CAjB2C,CAA9C;EAoBA,MAAMO,qBAAqB,GAAG,IAAIN,GAAJ,EAA9B;;EACAxF,YAAA,CAAMiC,QAAN,GAAiBN,KAAjB,CAAuBoE,OAAvB,CAA+BxC,IAAI,IAAI;IACrCuC,qBAAqB,CAACD,GAAtB,CAA0B,IAAArI,qCAAA,EAAsB,QAAtB,EAA+B+F,IAAI,CAAC9D,IAApC,CAA1B;EACD,CAFD;;EAIA,MAAMuG,gBAAsC,GAAG,EAA/C;EACAX,+BAA+B,CAACU,OAAhC,CAAwCE,gBAAgB,IAAI;IAC1D,IAAI,CAACH,qBAAqB,CAACI,GAAtB,CAA0BD,gBAA1B,CAAL,EAAkD;MAChDD,gBAAgB,CAACrB,IAAjB,CAAsBjH,gBAAA,CAAGM,MAAH,CAAUiI,gBAAV,CAAtB;IACD;EACF,CAJD;EAMA,MAAMhI,OAAO,CAACkI,GAAR,CAAYH,gBAAZ,CAAN;EAEAb,QAAQ,CAACL,GAAT;AACD"}
@@ -1,12 +1,12 @@
1
1
  import type { IGatsbyNode } from "../redux/types";
2
2
  import type { GatsbyIterable } from "../datastore/common/iterable";
3
- declare type data = IGatsbyNode | GatsbyIterable<IGatsbyNode>;
3
+ declare type Data = IGatsbyNode | GatsbyIterable<IGatsbyNode>;
4
+ declare type sanitizeNode = (data: Data, isNode?: boolean, path?: Set<unknown>) => Data | undefined;
4
5
  /**
5
6
  * Make data serializable
6
7
  * @param {(Object|Array)} data to sanitize
7
8
  * @param {boolean} isNode = true
8
9
  * @param {Set<string>} path = new Set
9
10
  */
10
- declare type sanitizeNode = (data: data, isNode?: boolean, path?: Set<unknown>) => data | undefined;
11
- declare const sanitizeNode: sanitizeNode;
12
- export default sanitizeNode;
11
+ export declare const sanitizeNode: sanitizeNode;
12
+ export {};
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.default = void 0;
6
+ exports.sanitizeNode = void 0;
7
7
 
8
8
  var _each2 = _interopRequireDefault(require("lodash/each"));
9
9
 
@@ -13,6 +13,10 @@ var _pickBy2 = _interopRequireDefault(require("lodash/pickBy"));
13
13
 
14
14
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
15
15
 
16
+ /**
17
+ * @param {Object|Array} data
18
+ * @returns {Object|Array} data without undefined values
19
+ */
16
20
  const omitUndefined = data => {
17
21
  const isPlainObject = (0, _isPlainObject2.default)(data);
18
22
 
@@ -22,12 +26,11 @@ const omitUndefined = data => {
22
26
 
23
27
  return data.filter(p => p !== undefined);
24
28
  };
29
+
25
30
  /**
26
31
  * @param {*} data
27
- * @return {boolean}
32
+ * @return {boolean} Boolean if type is supported
28
33
  */
29
-
30
-
31
34
  const isTypeSupported = data => {
32
35
  if (data === null) {
33
36
  return true;
@@ -37,35 +40,54 @@ const isTypeSupported = data => {
37
40
  const isSupported = type === `number` || type === `string` || type === `boolean` || data instanceof Date;
38
41
  return isSupported;
39
42
  };
43
+
40
44
  /**
41
45
  * Make data serializable
42
46
  * @param {(Object|Array)} data to sanitize
43
47
  * @param {boolean} isNode = true
44
48
  * @param {Set<string>} path = new Set
45
49
  */
46
-
47
-
48
50
  const sanitizeNode = (data, isNode = true, path = new Set()) => {
49
51
  const isPlainObject = (0, _isPlainObject2.default)(data);
52
+ const isArray = (0, _isArray2.default)(data);
50
53
 
51
- if (isPlainObject || (0, _isArray2.default)(data)) {
54
+ if (isPlainObject || isArray) {
52
55
  if (path.has(data)) return data;
53
56
  path.add(data);
54
57
  const returnData = isPlainObject ? {} : [];
55
- let anyFieldChanged = false;
56
- (0, _each2.default)(data, (o, key) => {
58
+ let anyFieldChanged = false; // _.each is a "Collection" method and thus objects with "length" property are iterated as arrays
59
+
60
+ const hasLengthProperty = isPlainObject ? Object.prototype.hasOwnProperty.call(data, `length`) : false;
61
+ let lengthProperty;
62
+
63
+ if (hasLengthProperty) {
64
+ lengthProperty = data.length;
65
+ delete data.length;
66
+ }
67
+
68
+ (0, _each2.default)(data, (value, key) => {
57
69
  if (isNode && key === `internal`) {
58
- returnData[key] = o;
70
+ returnData[key] = value;
59
71
  return;
60
72
  }
61
73
 
62
- returnData[key] = sanitizeNode(o, false, path);
74
+ returnData[key] = sanitizeNode(value, false, path);
63
75
 
64
- if (returnData[key] !== o) {
76
+ if (returnData[key] !== value) {
65
77
  anyFieldChanged = true;
66
78
  }
67
79
  });
68
80
 
81
+ if (hasLengthProperty) {
82
+ ;
83
+ data.length = lengthProperty;
84
+ returnData.length = sanitizeNode(lengthProperty, false, path);
85
+
86
+ if (returnData.length !== lengthProperty) {
87
+ anyFieldChanged = true;
88
+ }
89
+ }
90
+
69
91
  if (anyFieldChanged) {
70
92
  data = omitUndefined(returnData);
71
93
  } // arrays and plain objects are supported - no need to to sanitize
@@ -81,6 +103,5 @@ const sanitizeNode = (data, isNode = true, path = new Set()) => {
81
103
  }
82
104
  };
83
105
 
84
- var _default = sanitizeNode;
85
- exports.default = _default;
106
+ exports.sanitizeNode = sanitizeNode;
86
107
  //# sourceMappingURL=sanitize-node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-node.js","names":["omitUndefined","data","isPlainObject","p","undefined","filter","isTypeSupported","type","isSupported","Date","sanitizeNode","isNode","path","Set","has","add","returnData","anyFieldChanged","o","key"],"sources":["../../src/utils/sanitize-node.ts"],"sourcesContent":["import _ from \"lodash\"\n\nimport type { IGatsbyNode } from \"../redux/types\"\nimport type { GatsbyIterable } from \"../datastore/common/iterable\"\n\ntype data = IGatsbyNode | GatsbyIterable<IGatsbyNode>\n\n/**\n * @param {Object|Array} data\n * @returns {Object|Array} data without undefined values\n */\ntype omitUndefined = (data: data) => Partial<data>\n\nconst omitUndefined: omitUndefined = data => {\n const isPlainObject = _.isPlainObject(data)\n if (isPlainObject) {\n return _.pickBy(data, p => p !== undefined)\n }\n\n return (data as GatsbyIterable<IGatsbyNode>).filter(p => p !== undefined)\n}\n\n/**\n * @param {*} data\n * @return {boolean}\n */\ntype isTypeSupported = (data: data) => boolean\n\nconst isTypeSupported: isTypeSupported = data => {\n if (data === null) {\n return true\n }\n\n const type = typeof data\n const isSupported =\n type === `number` ||\n type === `string` ||\n type === `boolean` ||\n data instanceof Date\n\n return isSupported\n}\n\n/**\n * Make data serializable\n * @param {(Object|Array)} data to sanitize\n * @param {boolean} isNode = true\n * @param {Set<string>} path = new Set\n */\n\ntype sanitizeNode = (\n data: data,\n isNode?: boolean,\n path?: Set<unknown>\n) => data | undefined\n\nconst sanitizeNode: sanitizeNode = (data, isNode = true, path = new Set()) => {\n const isPlainObject = _.isPlainObject(data)\n\n if (isPlainObject || _.isArray(data)) {\n if (path.has(data)) return data\n path.add(data)\n\n const returnData = isPlainObject ? {} : []\n let anyFieldChanged = false\n _.each(data, (o, key) => {\n if (isNode && key === `internal`) {\n returnData[key] = o\n return\n }\n returnData[key] = sanitizeNode(o as data, false, path)\n\n if (returnData[key] !== o) {\n anyFieldChanged = true\n }\n })\n\n if (anyFieldChanged) {\n data = omitUndefined(returnData as data) as data\n }\n\n // arrays and plain objects are supported - no need to to sanitize\n return data\n }\n\n if (!isTypeSupported(data)) {\n return undefined\n } else {\n return data\n }\n}\n\nexport default sanitizeNode\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAMA,aAA4B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,aAAa,GAAG,6BAAgBD,IAAhB,CAAtB;;EACA,IAAIC,aAAJ,EAAmB;IACjB,OAAO,sBAASD,IAAT,EAAeE,CAAC,IAAIA,CAAC,KAAKC,SAA1B,CAAP;EACD;;EAED,OAAQH,IAAD,CAAsCI,MAAtC,CAA6CF,CAAC,IAAIA,CAAC,KAAKC,SAAxD,CAAP;AACD,CAPD;AASA;AACA;AACA;AACA;;;AAGA,MAAME,eAAgC,GAAGL,IAAI,IAAI;EAC/C,IAAIA,IAAI,KAAK,IAAb,EAAmB;IACjB,OAAO,IAAP;EACD;;EAED,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,CAlCD;;eAoCeS,Y"}
1
+ {"version":3,"file":"sanitize-node.js","names":["omitUndefined","data","isPlainObject","p","undefined","filter","isTypeSupported","type","isSupported","Date","sanitizeNode","isNode","path","Set","isArray","has","add","returnData","anyFieldChanged","hasLengthProperty","Object","prototype","hasOwnProperty","call","lengthProperty","length","value","key"],"sources":["../../src/utils/sanitize-node.ts"],"sourcesContent":["import _ from \"lodash\"\n\nimport type { IGatsbyNode } from \"../redux/types\"\nimport type { GatsbyIterable } from \"../datastore/common/iterable\"\n\ntype Data = IGatsbyNode | GatsbyIterable<IGatsbyNode>\n\ntype OmitUndefined = (data: Data) => Partial<Data>\n\n/**\n * @param {Object|Array} data\n * @returns {Object|Array} data without undefined values\n */\nconst omitUndefined: OmitUndefined = data => {\n const isPlainObject = _.isPlainObject(data)\n if (isPlainObject) {\n return _.pickBy(data, p => p !== undefined)\n }\n\n return (data as GatsbyIterable<IGatsbyNode>).filter(p => p !== undefined)\n}\n\ntype isTypeSupported = (data: Data) => boolean\n\n/**\n * @param {*} data\n * @return {boolean} Boolean if type is supported\n */\nconst isTypeSupported: isTypeSupported = data => {\n if (data === null) {\n return true\n }\n\n const type = typeof data\n const isSupported =\n type === `number` ||\n type === `string` ||\n type === `boolean` ||\n data instanceof Date\n\n return isSupported\n}\n\ntype sanitizeNode = (\n data: Data,\n isNode?: boolean,\n path?: Set<unknown>\n) => Data | undefined\n\n/**\n * Make data serializable\n * @param {(Object|Array)} data to sanitize\n * @param {boolean} isNode = true\n * @param {Set<string>} path = new Set\n */\nexport const sanitizeNode: sanitizeNode = (\n data,\n isNode = true,\n path = new Set()\n) => {\n const isPlainObject = _.isPlainObject(data)\n const isArray = _.isArray(data)\n\n if (isPlainObject || isArray) {\n if (path.has(data)) return data\n path.add(data)\n\n const returnData = isPlainObject\n ? ({} as IGatsbyNode)\n : ([] as Array<IGatsbyNode>)\n let anyFieldChanged = false\n\n // _.each is a \"Collection\" method and thus objects with \"length\" property are iterated as arrays\n const hasLengthProperty = isPlainObject\n ? Object.prototype.hasOwnProperty.call(data, `length`)\n : false\n let lengthProperty\n if (hasLengthProperty) {\n lengthProperty = (data as IGatsbyNode).length\n delete (data as IGatsbyNode).length\n }\n\n _.each(data, (value, key) => {\n if (isNode && key === `internal`) {\n returnData[key] = value\n return\n }\n returnData[key] = sanitizeNode(value as Data, false, path)\n\n if (returnData[key] !== value) {\n anyFieldChanged = true\n }\n })\n\n if (hasLengthProperty) {\n ;(data as IGatsbyNode).length = lengthProperty\n returnData.length = sanitizeNode(lengthProperty as Data, false, path)\n if (returnData.length !== lengthProperty) {\n anyFieldChanged = true\n }\n }\n\n if (anyFieldChanged) {\n data = omitUndefined(returnData as Data) as Data\n }\n\n // arrays and plain objects are supported - no need to to sanitize\n return data\n }\n\n if (!isTypeSupported(data)) {\n return undefined\n } else {\n return data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA;AACA;AACA;AACA;AACA,MAAMA,aAA4B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,aAAa,GAAG,6BAAgBD,IAAhB,CAAtB;;EACA,IAAIC,aAAJ,EAAmB;IACjB,OAAO,sBAASD,IAAT,EAAeE,CAAC,IAAIA,CAAC,KAAKC,SAA1B,CAAP;EACD;;EAED,OAAQH,IAAD,CAAsCI,MAAtC,CAA6CF,CAAC,IAAIA,CAAC,KAAKC,SAAxD,CAAP;AACD,CAPD;;AAWA;AACA;AACA;AACA;AACA,MAAME,eAAgC,GAAGL,IAAI,IAAI;EAC/C,IAAIA,IAAI,KAAK,IAAb,EAAmB;IACjB,OAAO,IAAP;EACD;;EAED,MAAMM,IAAI,GAAG,OAAON,IAApB;EACA,MAAMO,WAAW,GACfD,IAAI,KAAM,QAAV,IACAA,IAAI,KAAM,QADV,IAEAA,IAAI,KAAM,SAFV,IAGAN,IAAI,YAAYQ,IAJlB;EAMA,OAAOD,WAAP;AACD,CAbD;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,YAA0B,GAAG,CACxCT,IADw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AzB,EAAgCZ,IAAhC,CAAhC;;MACA,IAAIK,UAAU,CAACQ,MAAX,KAAsBD,cAA1B,EAA0C;QACxCN,eAAe,GAAG,IAAlB;MACD;IACF;;IAED,IAAIA,eAAJ,EAAqB;MACnBjB,IAAI,GAAGD,aAAa,CAACiB,UAAD,CAApB;IACD,CAzC2B,CA2C5B;;;IACA,OAAOhB,IAAP;EACD;;EAED,IAAI,CAACK,eAAe,CAACL,IAAD,CAApB,EAA4B;IAC1B,OAAOG,SAAP;EACD,CAFD,MAEO;IACL,OAAOH,IAAP;EACD;AACF,CA5DM"}
package/index.d.ts CHANGED
@@ -431,12 +431,34 @@ export interface GatsbyNode<
431
431
  * transform nodes created by other plugins should implement this API.
432
432
  *
433
433
  * See also the documentation for `createNode`
434
- * and [`createNodeField`](https://www.gatsbyjs.com/docs/actions/#createNodeField)
434
+ * and [`createNodeField`](https://www.gatsbyjs.com/docs/reference/config-files/actions/#createNodeField)
435
+ * @param {object} $0
436
+ * @param {object} $0.node A node object.
437
+ * @param {object} $0.actions
438
+ * @param {function} $0.actions.createNode Create a new node.
439
+ * @param {function} $0.actions.createNodeField Extend another node. The new node field is placed under the fields key on the extended node object.
435
440
  * @example
436
- * exports.onCreateNode = ({ node, actions }) => {
437
- * const { createNode, createNodeField } = actions
438
- * // Transform the new node here and create a new node or
439
- * // create a new node field.
441
+ * exports.onCreateNode = ({ node, getNode, actions }) => {
442
+ * const { createNodeField } = actions
443
+ *
444
+ * if (node.internal.type === `MarkdownRemark`) {
445
+ * const nodePath = node.fileAbsolutePath
446
+ *
447
+ * if (nodePath.match(/\/blog\//)) {
448
+ * const postSlug = createFilePath({
449
+ * node,
450
+ * getNode,
451
+ * basePath: `src/content`,
452
+ * trailingSlash: true,
453
+ * })
454
+ *
455
+ * createNodeField({
456
+ * node,
457
+ * name: `slug`,
458
+ * value: `/blog/${postSlug}/`,
459
+ * })
460
+ * }
461
+ * }
440
462
  * }
441
463
  */
442
464
  onCreateNode?(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby",
3
3
  "description": "Blazing fast modern site generator for React",
4
- "version": "5.2.0-next.1",
4
+ "version": "5.2.0",
5
5
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
6
6
  "bin": {
7
7
  "gatsby": "./cli.js"
@@ -48,8 +48,8 @@
48
48
  "babel-plugin-add-module-exports": "^1.0.4",
49
49
  "babel-plugin-dynamic-import-node": "^2.3.3",
50
50
  "babel-plugin-lodash": "^3.3.4",
51
- "babel-plugin-remove-graphql-queries": "^5.2.0-next.0",
52
- "babel-preset-gatsby": "^3.2.0-next.0",
51
+ "babel-plugin-remove-graphql-queries": "^5.2.0",
52
+ "babel-preset-gatsby": "^3.2.0",
53
53
  "better-opn": "^2.1.1",
54
54
  "bluebird": "^3.7.2",
55
55
  "browserslist": "^4.17.5",
@@ -90,20 +90,20 @@
90
90
  "find-cache-dir": "^3.3.2",
91
91
  "fs-exists-cached": "1.0.0",
92
92
  "fs-extra": "^10.1.0",
93
- "gatsby-cli": "^5.2.0-next.1",
94
- "gatsby-core-utils": "^4.2.0-next.0",
95
- "gatsby-graphiql-explorer": "^3.2.0-next.0",
96
- "gatsby-legacy-polyfills": "^3.2.0-next.0",
97
- "gatsby-link": "^5.2.0-next.0",
98
- "gatsby-page-utils": "^3.2.0-next.0",
99
- "gatsby-parcel-config": "1.2.0-next.0",
100
- "gatsby-plugin-page-creator": "^5.2.0-next.0",
101
- "gatsby-plugin-typescript": "^5.2.0-next.0",
102
- "gatsby-plugin-utils": "^4.2.0-next.0",
103
- "gatsby-react-router-scroll": "^6.2.0-next.0",
104
- "gatsby-script": "^2.2.0-next.1",
105
- "gatsby-telemetry": "^4.2.0-next.0",
106
- "gatsby-worker": "^2.2.0-next.0",
93
+ "gatsby-cli": "^5.2.0",
94
+ "gatsby-core-utils": "^4.2.0",
95
+ "gatsby-graphiql-explorer": "^3.2.0",
96
+ "gatsby-legacy-polyfills": "^3.2.0",
97
+ "gatsby-link": "^5.2.0",
98
+ "gatsby-page-utils": "^3.2.0",
99
+ "gatsby-parcel-config": "^1.2.0",
100
+ "gatsby-plugin-page-creator": "^5.2.0",
101
+ "gatsby-plugin-typescript": "^5.2.0",
102
+ "gatsby-plugin-utils": "^4.2.0",
103
+ "gatsby-react-router-scroll": "^6.2.0",
104
+ "gatsby-script": "^2.2.0",
105
+ "gatsby-telemetry": "^4.2.0",
106
+ "gatsby-worker": "^2.2.0",
107
107
  "glob": "^7.2.3",
108
108
  "globby": "^11.1.0",
109
109
  "got": "^11.8.5",
@@ -195,7 +195,7 @@
195
195
  "@types/string-similarity": "^4.0.0",
196
196
  "@types/tmp": "^0.2.0",
197
197
  "@types/webpack-virtual-modules": "^0.1.1",
198
- "babel-preset-gatsby-package": "^3.2.0-next.0",
198
+ "babel-preset-gatsby-package": "^3.2.0",
199
199
  "copyfiles": "^2.3.0",
200
200
  "cross-env": "^7.0.3",
201
201
  "documentation": "^13.1.0",
@@ -209,7 +209,7 @@
209
209
  "zipkin-transport-http": "^0.22.0"
210
210
  },
211
211
  "optionalDependencies": {
212
- "gatsby-sharp": "^1.2.0-next.0"
212
+ "gatsby-sharp": "^1.2.0"
213
213
  },
214
214
  "engines": {
215
215
  "node": ">=18.0.0"
@@ -277,5 +277,5 @@
277
277
  "yargs": {
278
278
  "boolean-negation": false
279
279
  },
280
- "gitHead": "63d4e655043e65b655e2af76c238f66bef74f6fc"
280
+ "gitHead": "cec2ab08bf08d96a02e224f0b02273d7529e80ae"
281
281
  }