gatsby 2.32.9 → 2.32.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/cache-dir/app.js +2 -3
- package/cache-dir/commonjs/app.js +2 -1
- package/dist/commands/build.js +5 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/develop-process.js +5 -1
- package/dist/commands/develop-process.js.map +1 -1
- package/dist/redux/actions/public.js +16 -6
- package/dist/redux/actions/public.js.map +1 -1
- package/dist/redux/nodes.js +5 -1
- package/dist/redux/nodes.js.map +1 -1
- package/dist/redux/reducers/status.d.ts +1 -0
- package/dist/redux/reducers/status.js +5 -0
- package/dist/redux/reducers/status.js.map +1 -1
- package/dist/redux/types.d.ts +1 -0
- package/dist/redux/types.js.map +1 -1
- package/dist/state-machines/develop/index.js +1 -3
- package/dist/state-machines/develop/index.js.map +1 -1
- package/dist/utils/dev-ssr/develop-html-route.js +3 -3
- package/dist/utils/dev-ssr/develop-html-route.js.map +1 -1
- package/dist/utils/dev-ssr/render-dev-html.js +3 -2
- package/dist/utils/dev-ssr/render-dev-html.js.map +1 -1
- package/dist/utils/develop-preload-headers.js +1 -1
- package/dist/utils/develop-preload-headers.js.map +1 -1
- package/gatsby-admin-public/4c744e84-6c27fb4a13dc8c8c3e88.js.map +1 -1
- package/gatsby-admin-public/69bd6bf3-00a5b50945cce68e041c.js.map +1 -1
- package/gatsby-admin-public/784b2cee55c07b638f20445dec340adf9f1888a3-d690a55f56dedc0f95b3.js.map +1 -1
- package/gatsby-admin-public/854a7ef1f34af0aefbdfdd9304a0c00251662775-30cef3c004238987a416.js.map +1 -1
- package/gatsby-admin-public/{app-ae73c37ae339da42b23e.js → app-749bdcbe1800236c1de3.js} +2 -2
- package/gatsby-admin-public/{app-ae73c37ae339da42b23e.js.LICENSE.txt → app-749bdcbe1800236c1de3.js.LICENSE.txt} +0 -0
- package/gatsby-admin-public/app-749bdcbe1800236c1de3.js.map +1 -0
- package/gatsby-admin-public/c432bec7e9afb3443fd639df9e5f119e13575cf7-976ea4aa8380d4a68cb1.js.map +1 -1
- package/gatsby-admin-public/chunk-map.json +1 -1
- package/gatsby-admin-public/component---src-pages-index-tsx-70aa31e4e1eca0a560a8.js.map +1 -1
- package/gatsby-admin-public/component---src-pages-plugins-tsx-c6700b48ed9ac88a9768.js.map +1 -1
- package/gatsby-admin-public/{component---src-pages-recipe-js-48fb05e6af01805f0a27.js → component---src-pages-recipe-js-e508d7ea0c80b0071ca7.js} +1 -1
- package/gatsby-admin-public/component---src-pages-recipe-js-e508d7ea0c80b0071ca7.js.map +1 -0
- package/gatsby-admin-public/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-fbd253211b90ee4d944c.js.map +1 -1
- package/gatsby-admin-public/framework-b5530edc347e85dd3979.js.map +1 -1
- package/gatsby-admin-public/index.html +1 -1
- package/gatsby-admin-public/page-data/app-data.json +1 -1
- package/gatsby-admin-public/pages/index.html +1 -1
- package/gatsby-admin-public/plugins/index.html +1 -1
- package/gatsby-admin-public/polyfill-dce23570cfd77335f976.js +2 -0
- package/gatsby-admin-public/polyfill-dce23570cfd77335f976.js.map +1 -0
- package/gatsby-admin-public/recipe/index.html +1 -1
- package/gatsby-admin-public/recipes/index.html +1 -1
- package/gatsby-admin-public/{webpack-runtime-ece0b6a1fdfb71d1b025.js → webpack-runtime-276364d320252125351e.js} +2 -2
- package/gatsby-admin-public/{webpack-runtime-ece0b6a1fdfb71d1b025.js.map → webpack-runtime-276364d320252125351e.js.map} +1 -1
- package/gatsby-admin-public/webpack.stats.json +1 -1
- package/package.json +7 -7
- package/gatsby-admin-public/app-ae73c37ae339da42b23e.js.map +0 -1
- package/gatsby-admin-public/component---src-pages-recipe-js-48fb05e6af01805f0a27.js.map +0 -1
- package/gatsby-admin-public/polyfill-3220228a1f93ed70393d.js +0 -2
- package/gatsby-admin-public/polyfill-3220228a1f93ed70393d.js.map +0 -1
package/dist/redux/nodes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/redux/nodes.ts"],"names":["getNodes","nodes","store","getState","Array","from","values","getNode","id","get","getNodesByType","type","nodesByType","getTypes","keys","hasNodeChanged","digest","node","internal","contentDigest","getNodeAndSavePathDependency","path","console","error","undefined","nodeId","saveResolvedNodes","nodeTypeNames","resolver","typeName","resolvedNodes","Map","resolved","set","dispatch","payload","key","getResolvedNode","resolvedNodesCache","__gatsby_resolved","postIndexingMetaSetup","filterCache","op","bucket","byValue","sort","a","b","counter","postIndexingMetaSetupNeNin","includes","postIndexingMetaSetupLtLteGtGte","arr","meta","nodesUnordered","forEach","v","push","entriesNullable","entries","filter","orderedNodes","orderedValues","offsets","length","valuesAsc","nodesByValueAsc","valueRangesAsc","valuesDesc","nodesByValueDesc","valueRangesDesc","ensureIndexByQuery","filterCacheKey","filterPath","filtersCache","state","addNodeToFilterCache","ensureEmptyFilterCache","orderedByCounter","chain","valueOffset","i","nextProp","isArray","markNodeForValue","value","ensureIndexByElemMatch","addNodeToBucketWithElemMatch","valueAtCurrentStep","nestedQuery","elem","binarySearchAsc","needle","min","max","pivot","Math","floor","binarySearchDesc","getNodesFromCacheByValue","filterValue","wasElemMatch","arrNull","arrUndef","unionNodesByCounter","Error","filterValueArr","Set","add","A","B","expensiveDedupeInline","removeBucketFromSet","RegExp","regex","test","String","ranges","range","slice","point","pivotMin","pivotMax","pivotValue","exclPivot","inclPivot","until","reverse","cache","delete","intersectNodesByCounter","pointerA","pointerB","result","maxA","maxB","lastAdded","nodeA","nodeB","counterA","counterB","prev","j"],"mappings":";;;;;;;;;AAAA;;AAEA;;AA8DA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,MAA0B;AAChD,QAAMC,KAAK,GAAGC,QAAMC,QAAN,GAAiBF,KAA/B;;AACA,MAAIA,KAAJ,EAAW;AACT,WAAOG,KAAK,CAACC,IAAN,CAAWJ,KAAK,CAACK,MAAN,EAAX,CAAP;AACD,GAFD,MAEO;A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hB;;AACA,QAAIhE,IAAI,KAAK4H,IAAb,EAAmB;AACjB;AACA,UAAI5D,CAAC,KAAK6D,CAAV,EAAa;AACX1F,QAAAA,GAAG,CAAC0F,CAAD,CAAH,GAAS7H,IAAT;AACD;;AACD,QAAE6H,CAAF;AACAD,MAAAA,IAAI,GAAG5H,IAAP;AACD;AACF;;AACDmC,EAAAA,GAAG,CAACY,MAAJ,GAAa8E,CAAb;AACD","sourcesContent":["import { store } from \"./\"\nimport { IGatsbyNode } from \"./types\"\nimport { createPageDependency } from \"./actions/add-page-dependency\"\nimport { IDbQueryElemMatch } from \"../db/common/query\"\n\n// Only list supported ops here. \"CacheableFilterOp\"\nexport type FilterOp = // TODO: merge with DbComparator ?\n | \"$eq\"\n | \"$ne\"\n | \"$lt\"\n | \"$lte\"\n | \"$gt\"\n | \"$gte\"\n | \"$in\"\n | \"$nin\"\n | \"$regex\" // Note: this includes $glob\n// Note: `undefined` is an encoding for a property that does not exist\nexport type FilterValueNullable = // TODO: merge with DbComparatorValue\n | string\n | number\n | boolean\n | null\n | undefined\n | RegExp // Only valid for $regex\n | Array<string | number | boolean | null | undefined>\n// This is filter value in most cases\ntype FilterValue =\n | string\n | number\n | boolean\n | RegExp // Only valid for $regex\n | Array<string | number | boolean>\nexport type FilterCacheKey = string\nexport interface IFilterCache {\n op: FilterOp\n // In this map `undefined` values represent nodes that did not have the path\n // The individual arrays are ordered asc by internal.counter which will\n // preserve insertion order and guarantee uniqueness and it's a number so our\n // .sort() calls can subtract one from the other which is nice :)\n // This arrays may contain duplicates (!) because those only get filtered in the\n // last step.\n // TODO: We might decide to make sure these buckets _are_ deduped for eq perf\n byValue: Map<FilterValueNullable, Array<IGatsbyNode>>\n meta: {\n // Used by ne/nin, which will create a Set from this array and then remove another set(s) and sort\n nodesUnordered?: Array<IGatsbyNode>\n // Flat list of all nodes by requested types, ordered by counter (cached for empty filters)\n orderedByCounter?: Array<IGatsbyNode>\n // Ordered list of all values (by `<`) found by this filter. No null / undefs\n valuesAsc?: Array<FilterValue>\n // Flat list of nodes, ordered by valueAsc\n nodesByValueAsc?: Array<IGatsbyNode>\n // Ranges of nodes per value, maps to the nodesByValueAsc array\n valueRangesAsc?: Map<FilterValue, [number, number]>\n // Ordered list of all values (by `>`) found by this filter. No null / undefs\n valuesDesc?: Array<FilterValue>\n // Flat list of nodes, ordered by valueDesc\n nodesByValueDesc?: Array<IGatsbyNode>\n // Ranges of nodes per value, maps to the nodesByValueDesc array\n valueRangesDesc?: Map<FilterValue, [number, number]>\n }\n}\nexport type FiltersCache = Map<FilterCacheKey, IFilterCache>\n\n/**\n * Get all nodes from redux store.\n */\nexport const getNodes = (): Array<IGatsbyNode> => {\n const nodes = store.getState().nodes\n if (nodes) {\n return Array.from(nodes.values())\n } else {\n return []\n }\n}\n\n/**\n * Get node by id from store.\n */\nexport const getNode = (id: string): IGatsbyNode | undefined =>\n store.getState().nodes.get(id)\n\n/**\n * Get all nodes of type from redux store.\n */\nexport const getNodesByType = (type: string): Array<IGatsbyNode> => {\n const nodes = store.getState().nodesByType.get(type)\n if (nodes) {\n return Array.from(nodes.values())\n } else {\n return []\n }\n}\n\n/**\n * Get all type names from redux store.\n */\nexport const getTypes = (): Array<string> =>\n Array.from(store.getState().nodesByType.keys())\n\n/**\n * Determine if node has changed.\n */\nexport const hasNodeChanged = (id: string, digest: string): boolean => {\n const node = store.getState().nodes.get(id)\n if (!node) {\n return true\n } else {\n return node.internal.contentDigest !== digest\n }\n}\n\n/**\n * Get node and save path dependency.\n */\nexport const getNodeAndSavePathDependency = (\n id: string,\n path: string\n): IGatsbyNode | undefined => {\n const node = getNode(id)\n\n if (!node) {\n console.error(\n `getNodeAndSavePathDependency failed for node id: ${id} as it was not found in cache`\n )\n return undefined\n }\n\n createPageDependency({ path, nodeId: id })\n return node\n}\n\ntype Resolver = (node: IGatsbyNode) => Promise<any> // TODO\n\nexport const saveResolvedNodes = async (\n nodeTypeNames: Array<string>,\n resolver: Resolver\n): Promise<void> => {\n for (const typeName of nodeTypeNames) {\n const nodes = store.getState().nodesByType.get(typeName)\n if (!nodes) continue\n\n const resolvedNodes = new Map()\n for (const node of nodes.values()) {\n const resolved = await resolver(node)\n resolvedNodes.set(node.id, resolved)\n }\n store.dispatch({\n type: `SET_RESOLVED_NODES`,\n payload: {\n key: typeName,\n nodes: resolvedNodes,\n },\n })\n }\n}\n\n/**\n * Get node and save path dependency.\n */\nexport const getResolvedNode = (\n typeName: string,\n id: string\n): IGatsbyNode | null => {\n const { nodesByType, resolvedNodesCache } = store.getState()\n const nodes = nodesByType.get(typeName)\n\n if (!nodes) {\n return null\n }\n\n const node = nodes.get(id)\n\n if (!node) {\n return null\n }\n\n const resolvedNodes = resolvedNodesCache.get(typeName)\n\n if (resolvedNodes) {\n node.__gatsby_resolved = resolvedNodes.get(id)\n }\n\n return node\n}\n\nexport function postIndexingMetaSetup(\n filterCache: IFilterCache,\n op: FilterOp\n): void {\n // Loop through byValue and make sure the buckets are sorted by counter\n // Since we don't do insertion sort, we have to do it afterwards\n for (const bucket of filterCache.byValue) {\n bucket[1].sort((a, b) => a.internal.counter - b.internal.counter)\n }\n\n if (op === `$ne` || op === `$nin`) {\n postIndexingMetaSetupNeNin(filterCache)\n } else if ([`$lt`, `$lte`, `$gt`, `$gte`].includes(op)) {\n postIndexingMetaSetupLtLteGtGte(filterCache, op)\n }\n}\n\nfunction postIndexingMetaSetupNeNin(filterCache: IFilterCache): void {\n // Note: edge cases regarding `null` and `undefined`. Here `undefined` signals\n // that the property did not exist as the filters do not support actual\n // `undefined` values.\n // For $ne, `null` only returns nodes that actually have the property\n // and in that case the property cannot be `null` either. For any other value,\n // $ne will return all nodes where the value is not actually the needle,\n // including nodes where the value is null.\n // A $nin does the same as an $ne except it filters multiple values instead\n // of just one.\n\n // For `$ne` we will take the list of all targeted nodes and eliminate the\n // bucket of nodes with a particular value, if it exists at all..\n\n const arr: Array<IGatsbyNode> = []\n filterCache.meta.nodesUnordered = arr\n filterCache.byValue.forEach(v => {\n v.forEach(node => {\n arr.push(node)\n })\n })\n}\n\nfunction postIndexingMetaSetupLtLteGtGte(\n filterCache: IFilterCache,\n op: FilterOp\n): void {\n // Create an ordered array of individual nodes, ordered (grouped) by the\n // value to which the filter resolves. Nodes per value are ordered by\n // internal.counter, asc.\n // This way non-eq ops can simply slice the array to get a range.\n\n const entriesNullable: Array<[FilterValueNullable, Array<IGatsbyNode>]> = [\n ...filterCache.byValue.entries(),\n ]\n\n // These range checks never return `null` or `undefined` so filter those out\n // By filtering them out early, the sort should be faster. Could be ...\n const entries: Array<[\n FilterValue,\n Array<IGatsbyNode>\n ]> = entriesNullable.filter(([v]) => v != null) as Array<\n [FilterValue, Array<IGatsbyNode>]\n >\n\n // Sort all arrays by its value, asc. Ignore/allow potential type casting.\n // Note: while `<` is the inverse of `>=`, the ordering might coerce values.\n // This coercion makes the op no longer idempotent (normally the result of\n // `a < b` is the opposite of `b >= a` for any a or b of the same type). The\n // exception is a number that is `NaN`, which we're ignoring here as it's most\n // likely a bug in the user code. However, when coercing the ops may end up\n // comparing against `NaN`, too. For example: `(\"abc\" <= 12) !== (12 > \"abc\")`\n // which ends up doing `NaN <= 12` and `NaN > \"abc\"`, which will both yield\n // false.\n // So instead we potentially track two ordered lists; ascending and descending\n // and the only difference when comparing the inverse of one to the other\n // should be how these `NaN` cases end up getting ordered.\n // It's fine for `lt` and `lte` to use the same ordered list. Same for gt/gte.\n if (op === `$lt` || op === `$lte`) {\n // Order ascending; first value is lowest\n entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n } else if (op === `$gt` || op === `$gte`) {\n // Order descending; first value is highest\n entries.sort(([a], [b]) => (a > b ? -1 : a < b ? 1 : 0))\n }\n\n const orderedNodes: Array<IGatsbyNode> = []\n const orderedValues: Array<FilterValue> = []\n const offsets: Map<FilterValue, [number, number]> = new Map()\n entries.forEach(([v, bucket]: [FilterValue, Array<IGatsbyNode>]) => {\n // Record the range containing all nodes with as filter value v\n // The last value of the range should be the offset of the next value\n // (So you should be able to do `nodes.slice(start, stop)` to get them)\n offsets.set(v, [orderedNodes.length, orderedNodes.length + bucket.length])\n // We could do `arr.push(...bucket)` here but that's not safe with very\n // large sets, so we use a regular loop\n bucket.forEach(node => orderedNodes.push(node))\n orderedValues.push(v)\n })\n\n if (op === `$lt` || op === `$lte`) {\n filterCache.meta.valuesAsc = orderedValues\n filterCache.meta.nodesByValueAsc = orderedNodes\n // The nodesByValueAsc is ordered by value, but multiple nodes per value are\n // not ordered. To make lt as fast as lte, we must know the start and stop\n // index for each value. Similarly useful for for `ne`.\n filterCache.meta.valueRangesAsc = offsets\n } else if (op === `$gt` || op === `$gte`) {\n filterCache.meta.valuesDesc = orderedValues\n filterCache.meta.nodesByValueDesc = orderedNodes\n // The nodesByValueDesc is ordered by value, but multiple nodes per value are\n // not ordered. To make gt as fast as gte, we must know the start and stop\n // index for each value. Similarly useful for for `ne`.\n filterCache.meta.valueRangesDesc = offsets\n }\n}\n\n/**\n * Given a single non-elemMatch filter path, a list of node types, and a\n * cache, create a cache that for each resulting value of the filter contains\n * all the Nodes in a list.\n * This cache is used for applying the filter and is a massive improvement over\n * looping over all the nodes, when the number of pages (/nodes) scales up.\n */\nexport const ensureIndexByQuery = (\n op: FilterOp,\n filterCacheKey: FilterCacheKey,\n filterPath: Array<string>,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void => {\n const state = store.getState()\n const resolvedNodesCache = state.resolvedNodesCache\n\n const filterCache: IFilterCache = {\n op,\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {},\n } as IFilterCache\n filtersCache.set(filterCacheKey, filterCache)\n\n // We cache the subsets of nodes by type, but only one type. So if searching\n // through one node type we can prevent a search through all nodes, otherwise\n // it's probably faster to loop through all nodes. Perhaps. Maybe.\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n addNodeToFilterCache(node, filterPath, filterCache, resolvedNodesCache)\n })\n } else {\n // Here we must first filter for the node type\n // This loop is expensive at scale (!)\n state.nodes.forEach(node => {\n if (!nodeTypeNames.includes(node.internal.type)) {\n return\n }\n\n addNodeToFilterCache(node, filterPath, filterCache, resolvedNodesCache)\n })\n }\n\n postIndexingMetaSetup(filterCache, op)\n}\n\nexport function ensureEmptyFilterCache(\n filterCacheKey,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void {\n // This is called for queries without any filters\n // We want to cache the result since it's basically a list of nodes by type(s)\n // There are sites that have multiple queries which are empty\n\n const state = store.getState()\n const resolvedNodesCache = state.resolvedNodesCache\n const orderedByCounter: Array<IGatsbyNode> = []\n\n filtersCache.set(filterCacheKey, {\n op: `$eq`, // Ignore.\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {\n orderedByCounter, // This is what we want\n },\n })\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n const resolved = resolvedNodes?.get(node.id)\n if (resolved !== undefined) {\n node.__gatsby_resolved = resolved\n }\n }\n orderedByCounter.push(node)\n })\n } else {\n // Here we must first filter for the node type\n // This loop is expensive at scale (!)\n state.nodes.forEach(node => {\n if (nodeTypeNames.includes(node.internal.type)) {\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n const resolved = resolvedNodes?.get(node.id)\n if (resolved !== undefined) {\n node.__gatsby_resolved = resolved\n }\n }\n orderedByCounter.push(node)\n }\n })\n }\n\n // Since each node can only have one type, we shouldn't have to be concerned\n // about duplicates in this array. Just make sure they're sorted.\n orderedByCounter.sort((a, b) => a.internal.counter - b.internal.counter)\n}\n\nfunction addNodeToFilterCache(\n node: IGatsbyNode,\n chain: Array<string>,\n filterCache: IFilterCache,\n resolvedNodesCache,\n valueOffset: any = node\n): void {\n // There can be a filter that targets `__gatsby_resolved` so fix that first\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n node.__gatsby_resolved = resolvedNodes?.get(node.id)\n }\n\n // - for plain query, valueOffset === node\n // - for elemMatch, valueOffset is sub-tree of the node to continue matching\n let v = valueOffset as any\n let i = 0\n while (i < chain.length && v) {\n const nextProp = chain[i++]\n v = v[nextProp]\n }\n\n if (\n (typeof v !== `string` &&\n typeof v !== `number` &&\n typeof v !== `boolean` &&\n v !== null) ||\n i !== chain.length\n ) {\n if (i === chain.length && Array.isArray(v)) {\n // The op resolved to an array\n // Add an entry for each element of the array. This would work for ops\n // like eq and ne, but not sure about range ops like lt,lte,gt,gte.\n\n v.forEach(v => markNodeForValue(filterCache, node, v))\n\n return\n }\n\n // This means that either\n // - The filter resolved to `undefined`, or\n // - The filter resolved to something other than a primitive\n // Set the value to `undefined` to mark \"path does not (fully) exist\"\n v = undefined\n }\n\n markNodeForValue(filterCache, node, v)\n}\n\nfunction markNodeForValue(\n filterCache: IFilterCache,\n node: IGatsbyNode,\n value: FilterValueNullable\n): void {\n let arr = filterCache.byValue.get(value)\n if (!arr) {\n arr = []\n filterCache.byValue.set(value, arr)\n }\n arr.push(node)\n}\n\nexport const ensureIndexByElemMatch = (\n op: FilterOp,\n filterCacheKey: FilterCacheKey,\n filter: IDbQueryElemMatch,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void => {\n // Given an elemMatch filter, generate the cache that contains all nodes that\n // matches a given value for that sub-query\n\n const state = store.getState()\n const { resolvedNodesCache } = state\n\n const filterCache: IFilterCache = {\n op,\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {},\n } as IFilterCache\n filtersCache.set(filterCacheKey, filterCache)\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n addNodeToBucketWithElemMatch(\n node,\n node,\n filter,\n filterCache,\n resolvedNodesCache\n )\n })\n } else {\n // Expensive at scale\n state.nodes.forEach(node => {\n if (!nodeTypeNames.includes(node.internal.type)) {\n return\n }\n\n addNodeToBucketWithElemMatch(\n node,\n node,\n filter,\n filterCache,\n resolvedNodesCache\n )\n })\n }\n\n postIndexingMetaSetup(filterCache, op)\n}\n\nfunction addNodeToBucketWithElemMatch(\n node: IGatsbyNode,\n valueAtCurrentStep: any, // Arbitrary step on the path inside the node\n filter: IDbQueryElemMatch,\n filterCache: IFilterCache,\n resolvedNodesCache\n): void {\n // There can be a filter that targets `__gatsby_resolved` so fix that first\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n node.__gatsby_resolved = resolvedNodes?.get(node.id)\n }\n\n const { path, nestedQuery } = filter\n\n // Find the value to apply elemMatch to\n let i = 0\n while (i < path.length && valueAtCurrentStep) {\n const nextProp = path[i++]\n valueAtCurrentStep = valueAtCurrentStep[nextProp]\n }\n\n if (path.length !== i) {\n // Found undefined before the end of the path\n return\n }\n\n // `v` should now be an elemMatch target, probably an array (but maybe not)\n if (!Array.isArray(valueAtCurrentStep)) {\n // It's possible to `elemMatch` on a non-array so let's support that too\n valueAtCurrentStep = [valueAtCurrentStep]\n }\n\n // Note: We need to check all elements because the node may need to be added\n // to multiple buckets (`{a:[{b:3},{b:4}]}`, for `a.elemMatch.b/eq` that\n // node ends up in buckets for value 3 and 4. This may lead to duplicate\n // work when elements resolve to the same value, but that can't be helped.\n valueAtCurrentStep.forEach(elem => {\n if (nestedQuery.type === `elemMatch`) {\n addNodeToBucketWithElemMatch(\n node,\n elem,\n nestedQuery,\n filterCache,\n resolvedNodesCache\n )\n } else {\n // Now take same route as non-elemMatch filters would take\n addNodeToFilterCache(\n node,\n nestedQuery.path,\n filterCache,\n resolvedNodesCache,\n elem\n )\n }\n })\n}\n\nconst binarySearchAsc = (\n values: Array<FilterValue>, // Assume ordered asc\n needle: FilterValue\n): [number, number] | undefined => {\n let min = 0\n let max = values.length - 1\n let pivot = Math.floor(values.length / 2)\n while (min <= max) {\n const value = values[pivot]\n if (needle < value) {\n // Move pivot to middle of nodes left of current pivot\n // assert pivot < max\n max = pivot\n } else if (needle > value) {\n // Move pivot to middle of nodes right of current pivot\n // assert pivot > min\n min = pivot\n } else {\n // This means needle === value\n // TODO: except for NaN ... and potentially certain type casting cases\n return [pivot, pivot]\n }\n\n if (max - min <= 1) {\n // End of search. Needle not found (as expected). Use pivot as index.\n // If the needle was not found, max-min==1 and max is returned.\n return [min, max]\n }\n\n pivot = min + Math.floor((max - min) / 2)\n }\n\n // Shouldn't be reachable\n return undefined\n}\nconst binarySearchDesc = (\n values: Array<FilterValue>, // Assume ordered desc\n needle: FilterValue\n): [number, number] | undefined => {\n let min = 0\n let max = values.length - 1\n let pivot = Math.floor(values.length / 2)\n while (min <= max) {\n const value = values[pivot]\n if (needle < value) {\n // Move pivot to middle of nodes right of current pivot\n // assert pivot < min\n min = pivot\n } else if (needle > value) {\n // Move pivot to middle of nodes left of current pivot\n // assert pivot > max\n max = pivot\n } else {\n // This means needle === value\n // TODO: except for NaN ... and potentially certain type casting cases\n return [pivot, pivot]\n }\n\n if (max - min <= 1) {\n // End of search. Needle not found (as expected). Use pivot as index.\n // If the needle was not found, max-min==1 and max is returned.\n return [min, max]\n }\n\n pivot = min + Math.floor((max - min) / 2)\n }\n\n // Shouldn't be reachable\n return undefined\n}\n\n/**\n * Given the cache key for a filter and a target value return the list of nodes\n * that resolve to this value. The returned array should be ordered by id.\n * This returns `undefined` if there is no such node\n *\n * Basically if the filter was {a: {b: {slug: {eq: \"foo/bar\"}}}} then it will\n * return all the nodes that have `node.slug === \"foo/bar\"`. That usually (but\n * not always) at most one node for slug, but this filter can apply to anything.\n *\n * Arrays returned by this function must be ordered by internal.counter and\n * not contain duplicate nodes (!)\n */\nexport const getNodesFromCacheByValue = (\n filterCacheKey: FilterCacheKey,\n filterValue: FilterValueNullable,\n filtersCache: FiltersCache,\n wasElemMatch\n): Array<IGatsbyNode> | undefined => {\n const filterCache = filtersCache.get(filterCacheKey)\n if (!filterCache) {\n return undefined\n }\n\n const op = filterCache.op\n\n if (op === `$eq`) {\n // Arrays in byValue are assumed to be ordered by counter\n\n if (filterValue == null) {\n // Edge case for null; fetch all nodes for `null` and `undefined` because\n // `$eq` also returns nodes without the path when searching for `null`.\n // Not all ops do so, so we map non-existing paths to `undefined`.\n\n const arrNull = filterCache.byValue.get(null) ?? []\n const arrUndef = filterCache.byValue.get(undefined) ?? []\n\n // Merge the two (ordered) arrays and return an ordered deduped array\n // TODO: is there a reason left why we cant just cache this merged list?\n return unionNodesByCounter(arrNull, arrUndef)\n }\n\n return filterCache.byValue.get(filterValue)\n }\n\n if (op === `$in`) {\n if (!Array.isArray(filterValue)) {\n throw new Error(\"The argument to the `in` comparator should be an array\")\n }\n const filterValueArr: Array<FilterValueNullable> = filterValue\n\n const set: Set<IGatsbyNode> = new Set()\n\n // TODO: we can also mergeSort for every step. this may perform worse because of how memory in js works.\n // For every value in the needle array, find the bucket of nodes for\n // that value, add this bucket of nodes to one list, return the list.\n filterValueArr.forEach((v: FilterValueNullable) =>\n filterCache.byValue.get(v)?.forEach(v => set.add(v))\n )\n\n const arr = [...set] // this is bad for perf but will guarantee us a unique set :(\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n\n // Note: it's very unlikely that the list of filter values is big so .includes should be fine here\n if (filterValueArr.includes(null)) {\n // Like all other ops, `in: [null]` behaves weirdly, allowing all nodes\n // that do not actually have a (complete) path (v=undefined)\n const nodes = filterCache.byValue.get(undefined)\n if (nodes) {\n // This will also dedupe so don't do that immediately\n return unionNodesByCounter(nodes, arr)\n }\n }\n\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe first\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n\n return arr\n }\n\n if (op === `$nin`) {\n // This is essentially the same as the $ne operator, just with multiple\n // values to exclude.\n\n if (!Array.isArray(filterValue)) {\n throw new Error(`The $nin operator expects an array as value`)\n }\n\n const values: Set<FilterValueNullable> = new Set(filterValue)\n const set = new Set(filterCache.meta.nodesUnordered)\n\n // Do the action for \"$ne\" for each element in the set of values\n values.forEach(filterValue => {\n removeBucketFromSet(filterValue, filterCache, set)\n })\n\n // TODO: there's probably a more efficient algorithm to do set\n // subtraction in such a way that we dont have to re-sort\n return [...set].sort((A, B) => A.internal.counter - B.internal.counter)\n }\n\n if (op === `$ne`) {\n const set = new Set(filterCache.meta.nodesUnordered)\n\n removeBucketFromSet(filterValue, filterCache, set)\n\n // TODO: there's probably a more efficient algorithm to do set\n // subtraction in such a way that we dont have to resort here\n return [...set].sort((A, B) => A.internal.counter - B.internal.counter)\n }\n\n if (op === `$regex`) {\n // Note: $glob is converted to $regex so $glob filters go through here, too\n // Aside from the input pattern format, further behavior is exactly the same.\n\n // The input to the filter must be a string (including leading/trailing slash and regex flags)\n // By the time the filter reaches this point, the filterValue has to be a regex.\n\n if (!(filterValue instanceof RegExp)) {\n throw new Error(\n `The value for the $regex comparator must be an instance of RegExp`\n )\n }\n const regex = filterValue\n\n const arr: Array<IGatsbyNode> = []\n filterCache.byValue.forEach((nodes, value) => {\n // TODO: does the value have to be a string for $regex? Can we auto-ignore any non-strings? Or does it coerce.\n // Note: for legacy reasons partial paths should also be included for regex\n if (value !== undefined && regex.test(String(value))) {\n nodes.forEach(node => arr.push(node))\n }\n })\n\n // TODO: we _can_ cache this list as well. Might make sense if it turns out that $regex is mostly used with literals\n // TODO: it may make sense to first collect all buckets and then to .concat them, or merge sort them\n\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n\n return arr\n }\n\n if (filterValue == null) {\n if (op === `$lt` || op === `$gt`) {\n // Nothing is lt/gt null\n return undefined\n }\n\n // This is an edge case and this value should be directly indexed\n // For `lte`/`gte` this should only return nodes for `null`, not a \"range\"\n return filterCache.byValue.get(filterValue)\n }\n\n if (Array.isArray(filterValue)) {\n throw new Error(\n \"Array is an invalid filter value for the `\" + op + \"` comparator\"\n )\n }\n\n if (filterValue instanceof RegExp) {\n // This is most likely an internal error, although it is possible for\n // users to talk to this API more directly.\n throw new Error(\n `A RegExp instance is only valid for $regex and $glob comparators`\n )\n }\n\n if (op === `$lt`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesAsc\n const nodes = filterCache.meta.nodesByValueAsc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[0])\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for lte, the valueAsc array must be list at this point\n const values = filterCache.meta.valuesAsc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchAsc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do lte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue > filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 <= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue < filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until)\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$lte`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesAsc\n const nodes = filterCache.meta.nodesByValueAsc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[1])\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for lte, the valueAsc array must be list at this point\n const values = filterCache.meta.valuesAsc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchAsc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do lte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue > filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 <= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue <= filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until)\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$gt`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesDesc\n const nodes = filterCache.meta.nodesByValueDesc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[0]).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for gte, the valueDesc array must be list at this point\n const values = filterCache.meta.valuesDesc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchDesc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do gte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue < filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 >= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue > filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$gte`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesDesc\n const nodes = filterCache.meta.nodesByValueDesc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[1]).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for gte, the valueDesc array must be list at this point\n const values = filterCache.meta.valuesDesc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchDesc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do gte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue < filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 >= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue >= filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Unreachable because we checked all values of FilterOp (which op is)\n return undefined\n}\n\nfunction removeBucketFromSet(\n filterValue: FilterValueNullable,\n filterCache: IFilterCache,\n set: Set<IGatsbyNode>\n): void {\n if (filterValue === null) {\n // Edge case: $ne with `null` returns only the nodes that contain the full\n // path and that don't resolve to null, so drop `undefined` as well.\n let cache = filterCache.byValue.get(undefined)\n if (cache) cache.forEach(node => set.delete(node))\n cache = filterCache.byValue.get(null)\n if (cache) cache.forEach(node => set.delete(node))\n } else {\n // Not excluding null so it should include undefined leafs or leafs where\n // only the partial path exists for whatever reason.\n const cache = filterCache.byValue.get(filterValue)\n if (cache) cache.forEach(node => set.delete(node))\n }\n}\n\n/**\n * Finds the intersection of two arrays in O(n) with n = min(a.length, b.length)\n * The returned set should not contain duplicate nodes.\n *\n * The input should be ordered by node.internal.counter and it will return a\n * list that is also ordered by node.internal.counter\n */\nexport function intersectNodesByCounter(\n a: Array<IGatsbyNode>,\n b: Array<IGatsbyNode>\n): Array<IGatsbyNode> {\n let pointerA = 0\n let pointerB = 0\n // TODO: perf check: is it helpful to init the array to min(maxA,maxB) items?\n const result: Array<IGatsbyNode> = []\n const maxA = a.length\n const maxB = b.length\n let lastAdded: IGatsbyNode | undefined = undefined // Used to dedupe the list\n\n while (pointerA < maxA && pointerB < maxB) {\n const nodeA = a[pointerA]\n const nodeB = b[pointerB]\n const counterA = nodeA.internal.counter\n const counterB = nodeB.internal.counter\n\n if (counterA < counterB) {\n pointerA++\n } else if (counterA > counterB) {\n pointerB++\n } else {\n // nodeA===nodeB. Make sure we didn't just add this node already.\n // Since input arrays are sorted, the same node should be grouped\n // back to back, so even if both input arrays contained the same node\n // twice, this check would prevent the result from getting duplicate nodes\n if (lastAdded !== nodeA) {\n result.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n pointerB++\n }\n }\n\n return result\n}\n\n/**\n * Merge two lists of nodes.\n * The returned set should not contain duplicate nodes.\n *\n * The input should be ordered by node.internal.counter and it will return a\n * list that is also ordered by node.internal.counter\n */\nexport function unionNodesByCounter(\n a: Array<IGatsbyNode>,\n b: Array<IGatsbyNode>\n): Array<IGatsbyNode> {\n // TODO: perf check: is it helpful to init the array to max(maxA,maxB) items?\n const arr: Array<IGatsbyNode> = []\n let lastAdded: IGatsbyNode | undefined = undefined // Used to dedupe the list\n\n let pointerA = 0\n let pointerB = 0\n const maxA = a.length\n const maxB = b.length\n\n while (pointerA < maxA && pointerB < maxB) {\n const nodeA = a[pointerA]\n const nodeB = b[pointerB]\n const counterA = nodeA.internal.counter\n const counterB = nodeB.internal.counter\n\n if (counterA < counterB) {\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n } else if (counterA > counterB) {\n if (lastAdded !== nodeB) {\n arr.push(nodeB)\n lastAdded = nodeB\n }\n pointerB++\n } else {\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n pointerB++\n }\n }\n\n while (pointerA < maxA) {\n const nodeA = a[pointerA]\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n }\n\n while (pointerB < maxB) {\n const nodeB = b[pointerB]\n if (lastAdded !== nodeB) {\n arr.push(nodeB)\n lastAdded = nodeB\n }\n pointerB++\n }\n\n return arr\n}\n\nfunction expensiveDedupeInline(arr: Array<IGatsbyNode>): void {\n // An elemMatch filter may cause duplicates to appear in a bucket.\n // Since the bucket is sorted those should now be back to back\n // Worst case this is a fast O(n) loop that does nothing.\n let prev: IGatsbyNode | undefined = undefined\n\n // We copy-on-find because a splice is expensive and we can't use Sets\n\n let j = 0\n for (let i = 0; i < arr.length; ++i) {\n const node = arr[i]\n if (node !== prev) {\n // Only start copying the remainder of the list once a dupe is found\n if (i !== j) {\n arr[j] = node\n }\n ++j\n prev = node\n }\n }\n arr.length = j\n}\n"],"file":"nodes.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/redux/nodes.ts"],"names":["getNodes","nodes","store","getState","Array","from","values","getNode","id","get","getNodesByType","type","nodesByType","getTypes","keys","hasNodeChanged","digest","node","internal","contentDigest","getNodeAndSavePathDependency","path","console","error","undefined","nodeId","saveResolvedNodes","nodeTypeNames","resolver","typeName","resolvedNodes","Map","resolved","set","dispatch","payload","key","getResolvedNode","resolvedNodesCache","__gatsby_resolved","postIndexingMetaSetup","filterCache","op","bucket","byValue","sort","a","b","counter","postIndexingMetaSetupNeNin","includes","postIndexingMetaSetupLtLteGtGte","arr","meta","nodesUnordered","forEach","v","push","entriesNullable","entries","filter","orderedNodes","orderedValues","offsets","length","valuesAsc","nodesByValueAsc","valueRangesAsc","valuesDesc","nodesByValueDesc","valueRangesDesc","ensureIndexByQuery","filterCacheKey","filterPath","filtersCache","state","addNodeToFilterCache","ensureEmptyFilterCache","orderedByCounter","chain","valueOffset","i","nextProp","isArray","markNodeForValue","value","ensureIndexByElemMatch","addNodeToBucketWithElemMatch","valueAtCurrentStep","nestedQuery","elem","binarySearchAsc","needle","min","max","pivot","Math","floor","binarySearchDesc","getNodesFromCacheByValue","filterValue","wasElemMatch","arrNull","arrUndef","unionNodesByCounter","Error","filterValueArr","Set","add","A","B","expensiveDedupeInline","removeBucketFromSet","RegExp","regex","test","String","ranges","range","slice","point","pivotMin","pivotMax","pivotValue","exclPivot","inclPivot","until","reverse","cache","delete","intersectNodesByCounter","pointerA","pointerB","result","maxA","maxB","lastAdded","nodeA","nodeB","counterA","counterB","prev","j"],"mappings":";;;;;;;;;AAAA;;AAEA;;AA8DA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,MAA0B;AAChD,QAAMC,KAAK,GAAGC,QAAMC,QAAN,GAAiBF,KAA/B;;AACA,MAAIA,KAAJ,EAAW;AACT,WAAOG,KAAK,CAACC,IAAN,CAAWJ,KAAK,CAACK,MAAN,EAAX,CAAP;AACD,GAFD,MAEO;AACL,WAAO,EAAP;AACD;AACF,CAPM;AASP;AACA;AACA;;;;;AACO,MAAMC,OAAO,GAAIC,EAAD,IACrBN,QAAMC,QAAN,GAAiBF,KAAjB,CAAuBQ,GAAvB,CAA2BD,EAA3B,CADK;AAGP;AACA;AACA;;;;;AACO,MAAME,cAAc,GAAIC,IAAD,IAAsC;AAClE,QAAMV,KAAK,GAAGC,QAAMC,QAAN,GAAiBS,WAAjB,CAA6BH,GAA7B,CAAiCE,IAAjC,CAAd;;AACA,MAAIV,KAAJ,EAAW;AACT,WAAOG,KAAK,CAACC,IAAN,CAAWJ,KAAK,CAACK,MAAN,EAAX,CAAP;AACD,GAFD,MAEO;AACL,WAAO,EAAP;AACD;AACF,CAPM;AASP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MAAAA,QAAQ;AACRC,MAAAA,QAAQ;AACT;AACF;;AAED,SAAOD,QAAQ,GAAGG,IAAlB,EAAwB;AACtB,UAAMG,KAAK,GAAG3F,CAAC,CAACqF,QAAD,CAAf;;AACA,QAAIK,SAAS,KAAKC,KAAlB,EAAyB;AACvBrF,MAAAA,GAAG,CAACK,IAAJ,CAASgF,KAAT;AACAD,MAAAA,SAAS,GAAGC,KAAZ;AACD;;AACDN,IAAAA,QAAQ;AACT;;AAED,SAAOC,QAAQ,GAAGG,IAAlB,EAAwB;AACtB,UAAMG,KAAK,GAAG3F,CAAC,CAACqF,QAAD,CAAf;;AACA,QAAII,SAAS,KAAKE,KAAlB,EAAyB;AACvBtF,MAAAA,GAAG,CAACK,IAAJ,CAASiF,KAAT;AACAF,MAAAA,SAAS,GAAGE,KAAZ;AACD;;AACDN,IAAAA,QAAQ;AACT;;AAED,SAAOhF,GAAP;AACD;;AAED,SAAS2D,qBAAT,CAA+B3D,GAA/B,EAA8D;AAC5D;AACA;AACA;AACA,MAAIyF,IAA6B,GAAGrH,SAApC,CAJ4D,CAM5D;;AAEA,MAAIsH,CAAC,GAAG,CAAR;;AACA,OAAK,IAAI7D,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG7B,GAAG,CAACY,MAAxB,EAAgC,EAAEiB,CAAlC,EAAqC;AACnC,UAAMhE,IAAI,GAAGmC,GAAG,CAAC6B,CAAD,CAAhB;;AACA,QAAIhE,IAAI,KAAK4H,IAAb,EAAmB;AACjB;AACA,UAAI5D,CAAC,KAAK6D,CAAV,EAAa;AACX1F,QAAAA,GAAG,CAAC0F,CAAD,CAAH,GAAS7H,IAAT;AACD;;AACD,QAAE6H,CAAF;AACAD,MAAAA,IAAI,GAAG5H,IAAP;AACD;AACF;;AACDmC,EAAAA,GAAG,CAACY,MAAJ,GAAa8E,CAAb;AACD","sourcesContent":["import { store } from \"./\"\nimport { IGatsbyNode } from \"./types\"\nimport { createPageDependency } from \"./actions/add-page-dependency\"\nimport { IDbQueryElemMatch } from \"../db/common/query\"\n\n// Only list supported ops here. \"CacheableFilterOp\"\nexport type FilterOp = // TODO: merge with DbComparator ?\n | \"$eq\"\n | \"$ne\"\n | \"$lt\"\n | \"$lte\"\n | \"$gt\"\n | \"$gte\"\n | \"$in\"\n | \"$nin\"\n | \"$regex\" // Note: this includes $glob\n// Note: `undefined` is an encoding for a property that does not exist\nexport type FilterValueNullable = // TODO: merge with DbComparatorValue\n | string\n | number\n | boolean\n | null\n | undefined\n | RegExp // Only valid for $regex\n | Array<string | number | boolean | null | undefined>\n// This is filter value in most cases\ntype FilterValue =\n | string\n | number\n | boolean\n | RegExp // Only valid for $regex\n | Array<string | number | boolean>\nexport type FilterCacheKey = string\nexport interface IFilterCache {\n op: FilterOp\n // In this map `undefined` values represent nodes that did not have the path\n // The individual arrays are ordered asc by internal.counter which will\n // preserve insertion order and guarantee uniqueness and it's a number so our\n // .sort() calls can subtract one from the other which is nice :)\n // This arrays may contain duplicates (!) because those only get filtered in the\n // last step.\n // TODO: We might decide to make sure these buckets _are_ deduped for eq perf\n byValue: Map<FilterValueNullable, Array<IGatsbyNode>>\n meta: {\n // Used by ne/nin, which will create a Set from this array and then remove another set(s) and sort\n nodesUnordered?: Array<IGatsbyNode>\n // Flat list of all nodes by requested types, ordered by counter (cached for empty filters)\n orderedByCounter?: Array<IGatsbyNode>\n // Ordered list of all values (by `<`) found by this filter. No null / undefs\n valuesAsc?: Array<FilterValue>\n // Flat list of nodes, ordered by valueAsc\n nodesByValueAsc?: Array<IGatsbyNode>\n // Ranges of nodes per value, maps to the nodesByValueAsc array\n valueRangesAsc?: Map<FilterValue, [number, number]>\n // Ordered list of all values (by `>`) found by this filter. No null / undefs\n valuesDesc?: Array<FilterValue>\n // Flat list of nodes, ordered by valueDesc\n nodesByValueDesc?: Array<IGatsbyNode>\n // Ranges of nodes per value, maps to the nodesByValueDesc array\n valueRangesDesc?: Map<FilterValue, [number, number]>\n }\n}\nexport type FiltersCache = Map<FilterCacheKey, IFilterCache>\n\n/**\n * Get all nodes from redux store.\n */\nexport const getNodes = (): Array<IGatsbyNode> => {\n const nodes = store.getState().nodes\n if (nodes) {\n return Array.from(nodes.values())\n } else {\n return []\n }\n}\n\n/**\n * Get node by id from store.\n */\nexport const getNode = (id: string): IGatsbyNode | undefined =>\n store.getState().nodes.get(id)\n\n/**\n * Get all nodes of type from redux store.\n */\nexport const getNodesByType = (type: string): Array<IGatsbyNode> => {\n const nodes = store.getState().nodesByType.get(type)\n if (nodes) {\n return Array.from(nodes.values())\n } else {\n return []\n }\n}\n\n/**\n * Get all type names from redux store.\n */\nexport const getTypes = (): Array<string> =>\n Array.from(store.getState().nodesByType.keys())\n\n/**\n * Determine if node has changed.\n */\nexport const hasNodeChanged = (id: string, digest: string): boolean => {\n const node = store.getState().nodes.get(id)\n if (!node) {\n return true\n } else {\n return node.internal.contentDigest !== digest\n }\n}\n\n/**\n * Get node and save path dependency.\n */\nexport const getNodeAndSavePathDependency = (\n id: string,\n path: string\n): IGatsbyNode | undefined => {\n const node = getNode(id)\n\n if (!node) {\n console.error(\n `getNodeAndSavePathDependency failed for node id: ${id} as it was not found in cache`\n )\n return undefined\n }\n\n createPageDependency({ path, nodeId: id })\n return node\n}\n\ntype Resolver = (node: IGatsbyNode) => Promise<any> // TODO\n\nexport const saveResolvedNodes = async (\n nodeTypeNames: Array<string>,\n resolver: Resolver\n): Promise<void> => {\n for (const typeName of nodeTypeNames) {\n const nodes = store.getState().nodesByType.get(typeName)\n if (!nodes) continue\n\n const resolvedNodes = new Map()\n for (const node of nodes.values()) {\n const resolved = await resolver(node)\n resolvedNodes.set(node.id, resolved)\n }\n store.dispatch({\n type: `SET_RESOLVED_NODES`,\n payload: {\n key: typeName,\n nodes: resolvedNodes,\n },\n })\n }\n}\n\n/**\n * Get node and save path dependency.\n */\nexport const getResolvedNode = (\n typeName: string,\n id: string\n): IGatsbyNode | null => {\n const { nodesByType, resolvedNodesCache } = store.getState()\n const nodes = nodesByType.get(typeName)\n\n if (!nodes) {\n return null\n }\n\n const node = nodes.get(id)\n\n if (!node) {\n return null\n }\n\n const resolvedNodes = resolvedNodesCache.get(typeName)\n\n if (resolvedNodes) {\n node.__gatsby_resolved = resolvedNodes.get(id)\n }\n\n return node\n}\n\nexport function postIndexingMetaSetup(\n filterCache: IFilterCache,\n op: FilterOp\n): void {\n // Loop through byValue and make sure the buckets are sorted by counter\n // Since we don't do insertion sort, we have to do it afterwards\n for (const bucket of filterCache.byValue) {\n bucket[1].sort((a, b) => a.internal.counter - b.internal.counter)\n }\n\n if (op === `$ne` || op === `$nin`) {\n postIndexingMetaSetupNeNin(filterCache)\n } else if ([`$lt`, `$lte`, `$gt`, `$gte`].includes(op)) {\n postIndexingMetaSetupLtLteGtGte(filterCache, op)\n }\n}\n\nfunction postIndexingMetaSetupNeNin(filterCache: IFilterCache): void {\n // Note: edge cases regarding `null` and `undefined`. Here `undefined` signals\n // that the property did not exist as the filters do not support actual\n // `undefined` values.\n // For $ne, `null` only returns nodes that actually have the property\n // and in that case the property cannot be `null` either. For any other value,\n // $ne will return all nodes where the value is not actually the needle,\n // including nodes where the value is null.\n // A $nin does the same as an $ne except it filters multiple values instead\n // of just one.\n\n // For `$ne` we will take the list of all targeted nodes and eliminate the\n // bucket of nodes with a particular value, if it exists at all..\n\n const arr: Array<IGatsbyNode> = []\n filterCache.meta.nodesUnordered = arr\n filterCache.byValue.forEach(v => {\n v.forEach(node => {\n arr.push(node)\n })\n })\n}\n\nfunction postIndexingMetaSetupLtLteGtGte(\n filterCache: IFilterCache,\n op: FilterOp\n): void {\n // Create an ordered array of individual nodes, ordered (grouped) by the\n // value to which the filter resolves. Nodes per value are ordered by\n // internal.counter, asc.\n // This way non-eq ops can simply slice the array to get a range.\n\n const entriesNullable: Array<[FilterValueNullable, Array<IGatsbyNode>]> = [\n ...filterCache.byValue.entries(),\n ]\n\n // These range checks never return `null` or `undefined` so filter those out\n // By filtering them out early, the sort should be faster. Could be ...\n const entries: Array<[\n FilterValue,\n Array<IGatsbyNode>\n ]> = entriesNullable.filter(([v]) => v != null) as Array<\n [FilterValue, Array<IGatsbyNode>]\n >\n\n // Sort all arrays by its value, asc. Ignore/allow potential type casting.\n // Note: while `<` is the inverse of `>=`, the ordering might coerce values.\n // This coercion makes the op no longer idempotent (normally the result of\n // `a < b` is the opposite of `b >= a` for any a or b of the same type). The\n // exception is a number that is `NaN`, which we're ignoring here as it's most\n // likely a bug in the user code. However, when coercing the ops may end up\n // comparing against `NaN`, too. For example: `(\"abc\" <= 12) !== (12 > \"abc\")`\n // which ends up doing `NaN <= 12` and `NaN > \"abc\"`, which will both yield\n // false.\n // So instead we potentially track two ordered lists; ascending and descending\n // and the only difference when comparing the inverse of one to the other\n // should be how these `NaN` cases end up getting ordered.\n // It's fine for `lt` and `lte` to use the same ordered list. Same for gt/gte.\n if (op === `$lt` || op === `$lte`) {\n // Order ascending; first value is lowest\n entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n } else if (op === `$gt` || op === `$gte`) {\n // Order descending; first value is highest\n entries.sort(([a], [b]) => (a > b ? -1 : a < b ? 1 : 0))\n }\n\n const orderedNodes: Array<IGatsbyNode> = []\n const orderedValues: Array<FilterValue> = []\n const offsets: Map<FilterValue, [number, number]> = new Map()\n entries.forEach(([v, bucket]: [FilterValue, Array<IGatsbyNode>]) => {\n // Record the range containing all nodes with as filter value v\n // The last value of the range should be the offset of the next value\n // (So you should be able to do `nodes.slice(start, stop)` to get them)\n offsets.set(v, [orderedNodes.length, orderedNodes.length + bucket.length])\n // We could do `arr.push(...bucket)` here but that's not safe with very\n // large sets, so we use a regular loop\n bucket.forEach(node => orderedNodes.push(node))\n orderedValues.push(v)\n })\n\n if (op === `$lt` || op === `$lte`) {\n filterCache.meta.valuesAsc = orderedValues\n filterCache.meta.nodesByValueAsc = orderedNodes\n // The nodesByValueAsc is ordered by value, but multiple nodes per value are\n // not ordered. To make lt as fast as lte, we must know the start and stop\n // index for each value. Similarly useful for for `ne`.\n filterCache.meta.valueRangesAsc = offsets\n } else if (op === `$gt` || op === `$gte`) {\n filterCache.meta.valuesDesc = orderedValues\n filterCache.meta.nodesByValueDesc = orderedNodes\n // The nodesByValueDesc is ordered by value, but multiple nodes per value are\n // not ordered. To make gt as fast as gte, we must know the start and stop\n // index for each value. Similarly useful for for `ne`.\n filterCache.meta.valueRangesDesc = offsets\n }\n}\n\n/**\n * Given a single non-elemMatch filter path, a list of node types, and a\n * cache, create a cache that for each resulting value of the filter contains\n * all the Nodes in a list.\n * This cache is used for applying the filter and is a massive improvement over\n * looping over all the nodes, when the number of pages (/nodes) scales up.\n */\nexport const ensureIndexByQuery = (\n op: FilterOp,\n filterCacheKey: FilterCacheKey,\n filterPath: Array<string>,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void => {\n const state = store.getState()\n const resolvedNodesCache = state.resolvedNodesCache\n\n const filterCache: IFilterCache = {\n op,\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {},\n } as IFilterCache\n filtersCache.set(filterCacheKey, filterCache)\n\n // We cache the subsets of nodes by type, but only one type. So if searching\n // through one node type we can prevent a search through all nodes, otherwise\n // it's probably faster to loop through all nodes. Perhaps. Maybe.\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n addNodeToFilterCache(node, filterPath, filterCache, resolvedNodesCache)\n })\n } else {\n // Here we must first filter for the node type\n // This loop is expensive at scale (!)\n state.nodes.forEach(node => {\n if (!nodeTypeNames.includes(node.internal.type)) {\n return\n }\n\n addNodeToFilterCache(node, filterPath, filterCache, resolvedNodesCache)\n })\n }\n\n postIndexingMetaSetup(filterCache, op)\n}\n\nexport function ensureEmptyFilterCache(\n filterCacheKey,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void {\n // This is called for queries without any filters\n // We want to cache the result since it's basically a list of nodes by type(s)\n // There are sites that have multiple queries which are empty\n\n const state = store.getState()\n const resolvedNodesCache = state.resolvedNodesCache\n const orderedByCounter: Array<IGatsbyNode> = []\n\n filtersCache.set(filterCacheKey, {\n op: `$eq`, // Ignore.\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {\n orderedByCounter, // This is what we want\n },\n })\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n const resolved = resolvedNodes?.get(node.id)\n if (resolved !== undefined) {\n node.__gatsby_resolved = resolved\n }\n }\n orderedByCounter.push(node)\n })\n } else {\n // Here we must first filter for the node type\n // This loop is expensive at scale (!)\n state.nodes.forEach(node => {\n if (nodeTypeNames.includes(node.internal.type)) {\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n const resolved = resolvedNodes?.get(node.id)\n if (resolved !== undefined) {\n node.__gatsby_resolved = resolved\n }\n }\n orderedByCounter.push(node)\n }\n })\n }\n\n // Since each node can only have one type, we shouldn't have to be concerned\n // about duplicates in this array. Just make sure they're sorted.\n orderedByCounter.sort((a, b) => a.internal.counter - b.internal.counter)\n}\n\nfunction addNodeToFilterCache(\n node: IGatsbyNode,\n chain: Array<string>,\n filterCache: IFilterCache,\n resolvedNodesCache,\n valueOffset: any = node\n): void {\n // There can be a filter that targets `__gatsby_resolved` so fix that first\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n node.__gatsby_resolved = resolvedNodes?.get(node.id)\n }\n\n // - for plain query, valueOffset === node\n // - for elemMatch, valueOffset is sub-tree of the node to continue matching\n let v = valueOffset as any\n let i = 0\n while (i < chain.length && v) {\n const nextProp = chain[i++]\n v = v[nextProp]\n }\n\n if (\n (typeof v !== `string` &&\n typeof v !== `number` &&\n typeof v !== `boolean` &&\n v !== null) ||\n i !== chain.length\n ) {\n if (i === chain.length && Array.isArray(v)) {\n // The op resolved to an array\n // Add an entry for each element of the array. This would work for ops\n // like eq and ne, but not sure about range ops like lt,lte,gt,gte.\n\n v.forEach(v => markNodeForValue(filterCache, node, v))\n\n return\n }\n\n // This means that either\n // - The filter resolved to `undefined`, or\n // - The filter resolved to something other than a primitive\n // Set the value to `undefined` to mark \"path does not (fully) exist\"\n v = undefined\n }\n\n markNodeForValue(filterCache, node, v)\n}\n\nfunction markNodeForValue(\n filterCache: IFilterCache,\n node: IGatsbyNode,\n value: FilterValueNullable\n): void {\n let arr = filterCache.byValue.get(value)\n if (!arr) {\n arr = []\n filterCache.byValue.set(value, arr)\n }\n arr.push(node)\n}\n\nexport const ensureIndexByElemMatch = (\n op: FilterOp,\n filterCacheKey: FilterCacheKey,\n filter: IDbQueryElemMatch,\n nodeTypeNames: Array<string>,\n filtersCache: FiltersCache\n): void => {\n // Given an elemMatch filter, generate the cache that contains all nodes that\n // matches a given value for that sub-query\n\n const state = store.getState()\n const { resolvedNodesCache } = state\n\n const filterCache: IFilterCache = {\n op,\n byValue: new Map<FilterValueNullable, Array<IGatsbyNode>>(),\n meta: {},\n } as IFilterCache\n filtersCache.set(filterCacheKey, filterCache)\n\n if (nodeTypeNames.length === 1) {\n getNodesByType(nodeTypeNames[0]).forEach(node => {\n addNodeToBucketWithElemMatch(\n node,\n node,\n filter,\n filterCache,\n resolvedNodesCache\n )\n })\n } else {\n // Expensive at scale\n state.nodes.forEach(node => {\n if (!nodeTypeNames.includes(node.internal.type)) {\n return\n }\n\n addNodeToBucketWithElemMatch(\n node,\n node,\n filter,\n filterCache,\n resolvedNodesCache\n )\n })\n }\n\n postIndexingMetaSetup(filterCache, op)\n}\n\nfunction addNodeToBucketWithElemMatch(\n node: IGatsbyNode,\n valueAtCurrentStep: any, // Arbitrary step on the path inside the node\n filter: IDbQueryElemMatch,\n filterCache: IFilterCache,\n resolvedNodesCache\n): void {\n // There can be a filter that targets `__gatsby_resolved` so fix that first\n if (!node.__gatsby_resolved) {\n const typeName = node.internal.type\n const resolvedNodes = resolvedNodesCache.get(typeName)\n node.__gatsby_resolved = resolvedNodes?.get(node.id)\n }\n\n const { path, nestedQuery } = filter\n\n // Find the value to apply elemMatch to\n let i = 0\n while (i < path.length && valueAtCurrentStep) {\n const nextProp = path[i++]\n valueAtCurrentStep = valueAtCurrentStep[nextProp]\n }\n\n if (path.length !== i) {\n // Found undefined before the end of the path\n return\n }\n\n // `v` should now be an elemMatch target, probably an array (but maybe not)\n if (!Array.isArray(valueAtCurrentStep)) {\n // It's possible to `elemMatch` on a non-array so let's support that too\n valueAtCurrentStep = [valueAtCurrentStep]\n }\n\n // Note: We need to check all elements because the node may need to be added\n // to multiple buckets (`{a:[{b:3},{b:4}]}`, for `a.elemMatch.b/eq` that\n // node ends up in buckets for value 3 and 4. This may lead to duplicate\n // work when elements resolve to the same value, but that can't be helped.\n valueAtCurrentStep.forEach(elem => {\n if (nestedQuery.type === `elemMatch`) {\n addNodeToBucketWithElemMatch(\n node,\n elem,\n nestedQuery,\n filterCache,\n resolvedNodesCache\n )\n } else {\n // Now take same route as non-elemMatch filters would take\n addNodeToFilterCache(\n node,\n nestedQuery.path,\n filterCache,\n resolvedNodesCache,\n elem\n )\n }\n })\n}\n\nconst binarySearchAsc = (\n values: Array<FilterValue>, // Assume ordered asc\n needle: FilterValue\n): [number, number] | undefined => {\n let min = 0\n let max = values.length - 1\n let pivot = Math.floor(values.length / 2)\n while (min <= max) {\n const value = values[pivot]\n if (needle < value) {\n // Move pivot to middle of nodes left of current pivot\n // assert pivot < max\n max = pivot\n } else if (needle > value) {\n // Move pivot to middle of nodes right of current pivot\n // assert pivot > min\n min = pivot\n } else {\n // This means needle === value\n // TODO: except for NaN ... and potentially certain type casting cases\n return [pivot, pivot]\n }\n\n if (max - min <= 1) {\n // End of search. Needle not found (as expected). Use pivot as index.\n // If the needle was not found, max-min==1 and max is returned.\n return [min, max]\n }\n\n pivot = min + Math.floor((max - min) / 2)\n }\n\n // Shouldn't be reachable\n return undefined\n}\nconst binarySearchDesc = (\n values: Array<FilterValue>, // Assume ordered desc\n needle: FilterValue\n): [number, number] | undefined => {\n let min = 0\n let max = values.length - 1\n let pivot = Math.floor(values.length / 2)\n while (min <= max) {\n const value = values[pivot]\n if (needle < value) {\n // Move pivot to middle of nodes right of current pivot\n // assert pivot < min\n min = pivot\n } else if (needle > value) {\n // Move pivot to middle of nodes left of current pivot\n // assert pivot > max\n max = pivot\n } else {\n // This means needle === value\n // TODO: except for NaN ... and potentially certain type casting cases\n return [pivot, pivot]\n }\n\n if (max - min <= 1) {\n // End of search. Needle not found (as expected). Use pivot as index.\n // If the needle was not found, max-min==1 and max is returned.\n return [min, max]\n }\n\n pivot = min + Math.floor((max - min) / 2)\n }\n\n // Shouldn't be reachable\n return undefined\n}\n\n/**\n * Given the cache key for a filter and a target value return the list of nodes\n * that resolve to this value. The returned array should be ordered by id.\n * This returns `undefined` if there is no such node\n *\n * Basically if the filter was {a: {b: {slug: {eq: \"foo/bar\"}}}} then it will\n * return all the nodes that have `node.slug === \"foo/bar\"`. That usually (but\n * not always) at most one node for slug, but this filter can apply to anything.\n *\n * Arrays returned by this function must be ordered by internal.counter and\n * not contain duplicate nodes (!)\n */\nexport const getNodesFromCacheByValue = (\n filterCacheKey: FilterCacheKey,\n filterValue: FilterValueNullable,\n filtersCache: FiltersCache,\n wasElemMatch\n): Array<IGatsbyNode> | undefined => {\n const filterCache = filtersCache.get(filterCacheKey)\n if (!filterCache) {\n return undefined\n }\n\n const op = filterCache.op\n\n if (op === `$eq`) {\n // Arrays in byValue are assumed to be ordered by counter\n\n if (filterValue == null) {\n // Edge case for null; fetch all nodes for `null` and `undefined` because\n // `$eq` also returns nodes without the path when searching for `null`.\n // Not all ops do so, so we map non-existing paths to `undefined`.\n\n const arrNull = filterCache.byValue.get(null) ?? []\n const arrUndef = filterCache.byValue.get(undefined) ?? []\n\n // Merge the two (ordered) arrays and return an ordered deduped array\n // TODO: is there a reason left why we cant just cache this merged list?\n return unionNodesByCounter(arrNull, arrUndef)\n }\n\n return filterCache.byValue.get(filterValue)\n }\n\n if (op === `$in`) {\n if (!Array.isArray(filterValue)) {\n throw new Error(\"The argument to the `in` comparator should be an array\")\n }\n const filterValueArr: Array<FilterValueNullable> = filterValue\n\n const set: Set<IGatsbyNode> = new Set()\n\n // TODO: we can also mergeSort for every step. this may perform worse because of how memory in js works.\n // For every value in the needle array, find the bucket of nodes for\n // that value, add this bucket of nodes to one list, return the list.\n filterValueArr.forEach((v: FilterValueNullable) =>\n filterCache.byValue.get(v)?.forEach(v => set.add(v))\n )\n\n const arr = [...set] // this is bad for perf but will guarantee us a unique set :(\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n\n // Note: it's very unlikely that the list of filter values is big so .includes should be fine here\n if (filterValueArr.includes(null)) {\n // Like all other ops, `in: [null]` behaves weirdly, allowing all nodes\n // that do not actually have a (complete) path (v=undefined)\n const nodes = filterCache.byValue.get(undefined)\n if (nodes) {\n // This will also dedupe so don't do that immediately\n return unionNodesByCounter(nodes, arr)\n }\n }\n\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe first\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n\n return arr\n }\n\n if (op === `$nin`) {\n // This is essentially the same as the $ne operator, just with multiple\n // values to exclude.\n\n if (!Array.isArray(filterValue)) {\n throw new Error(`The $nin operator expects an array as value`)\n }\n\n const values: Set<FilterValueNullable> = new Set(filterValue)\n const set = new Set(filterCache.meta.nodesUnordered)\n\n // Do the action for \"$ne\" for each element in the set of values\n values.forEach(filterValue => {\n removeBucketFromSet(filterValue, filterCache, set)\n })\n\n // TODO: there's probably a more efficient algorithm to do set\n // subtraction in such a way that we dont have to re-sort\n return [...set].sort((A, B) => A.internal.counter - B.internal.counter)\n }\n\n if (op === `$ne`) {\n const set = new Set(filterCache.meta.nodesUnordered)\n\n removeBucketFromSet(filterValue, filterCache, set)\n\n // TODO: there's probably a more efficient algorithm to do set\n // subtraction in such a way that we dont have to resort here\n return [...set].sort((A, B) => A.internal.counter - B.internal.counter)\n }\n\n if (op === `$regex`) {\n // Note: $glob is converted to $regex so $glob filters go through here, too\n // Aside from the input pattern format, further behavior is exactly the same.\n\n // The input to the filter must be a string (including leading/trailing slash and regex flags)\n // By the time the filter reaches this point, the filterValue has to be a regex.\n\n if (!(filterValue instanceof RegExp)) {\n throw new Error(\n `The value for the $regex comparator must be an instance of RegExp`\n )\n }\n const regex = filterValue\n\n const arr: Array<IGatsbyNode> = []\n filterCache.byValue.forEach((nodes, value) => {\n // TODO: does the value have to be a string for $regex? Can we auto-ignore any non-strings? Or does it coerce.\n // Note: for legacy reasons partial paths should also be included for regex\n if (value !== undefined && regex.test(String(value))) {\n nodes.forEach(node => arr.push(node))\n }\n })\n\n // TODO: we _can_ cache this list as well. Might make sense if it turns out that $regex is mostly used with literals\n // TODO: it may make sense to first collect all buckets and then to .concat them, or merge sort them\n\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n\n return arr\n }\n\n if (filterValue == null) {\n if (op === `$lt` || op === `$gt`) {\n // Nothing is lt/gt null\n return undefined\n }\n\n // This is an edge case and this value should be directly indexed\n // For `lte`/`gte` this should only return nodes for `null`, not a \"range\"\n return filterCache.byValue.get(filterValue)\n }\n\n if (Array.isArray(filterValue)) {\n throw new Error(\n \"Array is an invalid filter value for the `\" + op + \"` comparator\"\n )\n }\n\n if (filterValue instanceof RegExp) {\n // This is most likely an internal error, although it is possible for\n // users to talk to this API more directly.\n throw new Error(\n `A RegExp instance is only valid for $regex and $glob comparators`\n )\n }\n\n if (op === `$lt`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesAsc\n const nodes = filterCache.meta.nodesByValueAsc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[0])\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for lte, the valueAsc array must be list at this point\n const values = filterCache.meta.valuesAsc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchAsc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do lte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue > filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 <= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue < filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until)\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$lte`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesAsc\n const nodes = filterCache.meta.nodesByValueAsc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[1])\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for lte, the valueAsc array must be list at this point\n const values = filterCache.meta.valuesAsc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchAsc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do lte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue > filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 <= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue <= filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until)\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$gt`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesDesc\n const nodes = filterCache.meta.nodesByValueDesc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[0]).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for gte, the valueDesc array must be list at this point\n const values = filterCache.meta.valuesDesc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchDesc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do gte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue < filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 >= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue > filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n if (op === `$gte`) {\n // First try a direct approach. If a value is queried that also exists then\n // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n const ranges = filterCache.meta.valueRangesDesc\n const nodes = filterCache.meta.nodesByValueDesc\n\n const range = ranges!.get(filterValue)\n if (range) {\n const arr = nodes!.slice(0, range[1]).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Query may ask for a value that doesn't appear in the list, like if the\n // list is [1, 2, 5, 6] and the query is <= 3. In that case we have to\n // apply a search (we'll do binary) to determine the offset to slice from.\n\n // Note: for gte, the valueDesc array must be list at this point\n const values = filterCache.meta.valuesDesc as Array<FilterValue>\n // It shouldn't find the targetValue (but it might) and return the index of\n // the two value between which targetValue sits, or first/last element.\n const point = binarySearchDesc(values, filterValue)\n if (!point) {\n return undefined\n }\n const [pivotMin, pivotMax] = point\n\n // Each pivot index must have a value and a range\n // The returned min/max index may include the lower/upper bound, so we still\n // have to do gte checks for both values.\n let pivotValue = values[pivotMax]\n if (pivotValue < filterValue) {\n pivotValue = values[pivotMin]\n }\n\n // Note: the pivot value _shouldnt_ match the filter value because that\n // means the value was actually found, but those should have been indexed\n // so should have yielded a result in the .get() above.\n\n const [exclPivot, inclPivot] = ranges!.get(pivotValue) as [number, number]\n\n // Note: technically, `5 >= \"5\" === true` but `5` would not be cached.\n // So we have to consider weak comparison and may have to include the pivot\n const until = pivotValue >= filterValue ? inclPivot : exclPivot\n const arr = nodes!.slice(0, until).reverse()\n arr.sort((A, B) => A.internal.counter - B.internal.counter)\n // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n if (wasElemMatch) {\n expensiveDedupeInline(arr)\n }\n return arr\n }\n\n // Unreachable because we checked all values of FilterOp (which op is)\n return undefined\n}\n\nfunction removeBucketFromSet(\n filterValue: FilterValueNullable,\n filterCache: IFilterCache,\n set: Set<IGatsbyNode>\n): void {\n if (filterValue === null) {\n // Edge case: $ne with `null` returns only the nodes that contain the full\n // path and that don't resolve to null, so drop `undefined` as well.\n let cache = filterCache.byValue.get(undefined)\n if (cache) cache.forEach(node => set.delete(node))\n cache = filterCache.byValue.get(null)\n if (cache) cache.forEach(node => set.delete(node))\n } else {\n // Not excluding null so it should include undefined leafs or leafs where\n // only the partial path exists for whatever reason.\n const cache = filterCache.byValue.get(filterValue)\n if (cache) cache.forEach(node => set.delete(node))\n }\n}\n\n/**\n * Finds the intersection of two arrays in O(n) with n = min(a.length, b.length)\n * The returned set should not contain duplicate nodes.\n *\n * The input should be ordered by node.internal.counter and it will return a\n * list that is also ordered by node.internal.counter\n */\nexport function intersectNodesByCounter(\n a: Array<IGatsbyNode>,\n b: Array<IGatsbyNode>\n): Array<IGatsbyNode> {\n let pointerA = 0\n let pointerB = 0\n // TODO: perf check: is it helpful to init the array to min(maxA,maxB) items?\n const result: Array<IGatsbyNode> = []\n const maxA = a.length\n const maxB = b.length\n let lastAdded: IGatsbyNode | undefined = undefined // Used to dedupe the list\n\n while (pointerA < maxA && pointerB < maxB) {\n const nodeA = a[pointerA]\n const nodeB = b[pointerB]\n const counterA = nodeA.internal.counter\n const counterB = nodeB.internal.counter\n\n if (counterA < counterB) {\n pointerA++\n } else if (counterA > counterB) {\n pointerB++\n } else {\n if (nodeA !== nodeB) {\n throw new Error(\n `Invariant violation: inconsistent node counters detected`\n )\n }\n // nodeA===nodeB. Make sure we didn't just add this node already.\n // Since input arrays are sorted, the same node should be grouped\n // back to back, so even if both input arrays contained the same node\n // twice, this check would prevent the result from getting duplicate nodes\n if (lastAdded !== nodeA) {\n result.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n pointerB++\n }\n }\n\n return result\n}\n\n/**\n * Merge two lists of nodes.\n * The returned set should not contain duplicate nodes.\n *\n * The input should be ordered by node.internal.counter and it will return a\n * list that is also ordered by node.internal.counter\n */\nexport function unionNodesByCounter(\n a: Array<IGatsbyNode>,\n b: Array<IGatsbyNode>\n): Array<IGatsbyNode> {\n // TODO: perf check: is it helpful to init the array to max(maxA,maxB) items?\n const arr: Array<IGatsbyNode> = []\n let lastAdded: IGatsbyNode | undefined = undefined // Used to dedupe the list\n\n let pointerA = 0\n let pointerB = 0\n const maxA = a.length\n const maxB = b.length\n\n while (pointerA < maxA && pointerB < maxB) {\n const nodeA = a[pointerA]\n const nodeB = b[pointerB]\n const counterA = nodeA.internal.counter\n const counterB = nodeB.internal.counter\n\n if (counterA < counterB) {\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n } else if (counterA > counterB) {\n if (lastAdded !== nodeB) {\n arr.push(nodeB)\n lastAdded = nodeB\n }\n pointerB++\n } else {\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n pointerB++\n }\n }\n\n while (pointerA < maxA) {\n const nodeA = a[pointerA]\n if (lastAdded !== nodeA) {\n arr.push(nodeA)\n lastAdded = nodeA\n }\n pointerA++\n }\n\n while (pointerB < maxB) {\n const nodeB = b[pointerB]\n if (lastAdded !== nodeB) {\n arr.push(nodeB)\n lastAdded = nodeB\n }\n pointerB++\n }\n\n return arr\n}\n\nfunction expensiveDedupeInline(arr: Array<IGatsbyNode>): void {\n // An elemMatch filter may cause duplicates to appear in a bucket.\n // Since the bucket is sorted those should now be back to back\n // Worst case this is a fast O(n) loop that does nothing.\n let prev: IGatsbyNode | undefined = undefined\n\n // We copy-on-find because a splice is expensive and we can't use Sets\n\n let j = 0\n for (let i = 0; i < arr.length; ++i) {\n const node = arr[i]\n if (node !== prev) {\n // Only start copying the remainder of the list once a dupe is found\n if (i !== j) {\n arr[j] = node\n }\n ++j\n prev = node\n }\n }\n arr.length = j\n}\n"],"file":"nodes.js"}
|
|
@@ -2,4 +2,5 @@ import { ActionsUnion, IGatsbyState } from "../types";
|
|
|
2
2
|
export declare const statusReducer: (state: {
|
|
3
3
|
plugins: Record<string, import("../types").IGatsbyPlugin>;
|
|
4
4
|
PLUGINS_HASH: string;
|
|
5
|
+
LAST_NODE_COUNTER: number;
|
|
5
6
|
} | undefined, action: ActionsUnion) => IGatsbyState["status"];
|
|
@@ -9,6 +9,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
9
9
|
|
|
10
10
|
const defaultState = {
|
|
11
11
|
PLUGINS_HASH: ``,
|
|
12
|
+
LAST_NODE_COUNTER: 0,
|
|
12
13
|
plugins: {}
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -39,6 +40,10 @@ const statusReducer = (state = defaultState, action) => {
|
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
case `CREATE_NODE`:
|
|
44
|
+
state.LAST_NODE_COUNTER = action.payload.internal.counter;
|
|
45
|
+
return state;
|
|
46
|
+
|
|
42
47
|
default:
|
|
43
48
|
return state;
|
|
44
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/redux/reducers/status.ts"],"names":["defaultState","PLUGINS_HASH","plugins","statusReducer","state","action","type","payload","plugin","name","Error","_","isObject","JSON","stringify","merge"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,YAAoC,GAAG;AAC3CC,EAAAA,YAAY,EAAG,EAD4B;AAE3CC,EAAAA,OAAO,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../../src/redux/reducers/status.ts"],"names":["defaultState","PLUGINS_HASH","LAST_NODE_COUNTER","plugins","statusReducer","state","action","type","payload","plugin","name","Error","_","isObject","JSON","stringify","merge","internal","counter"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,YAAoC,GAAG;AAC3CC,EAAAA,YAAY,EAAG,EAD4B;AAE3CC,EAAAA,iBAAiB,EAAE,CAFwB;AAG3CC,EAAAA,OAAO,EAAE;AAHkC,CAA7C;;AAMO,MAAMC,aAAa,GAAG,CAC3BC,KAA6B,GAAGL,YADL,EAE3BM,MAF2B,KAGA;AAAA;;AAC3B,UAAQA,MAAM,CAACC,IAAf;AACE,SAAM,cAAN;AACE,aAAOP,YAAP;;AACF,SAAM,qBAAN;AACE,aAAO,EACL,GAAGK,KADE;AAELJ,QAAAA,YAAY,EAAEK,MAAM,CAACE;AAFhB,OAAP;;AAIF,SAAM,mBAAN;AACE,UAAI,CAACF,MAAM,CAACG,MAAR,IAAkB,oBAACH,MAAM,CAACG,MAAR,mDAAC,eAAeC,IAAhB,CAAtB,EAA4C;AAC1C,cAAM,IAAIC,KAAJ,CAAW,8CAAX,CAAN;AACD;;AACD,UAAI,CAACC,gBAAEC,QAAF,CAAWP,MAAM,CAACE,OAAlB,CAAL,EAAiC;AAC/B,cAAM,IAAIG,KAAJ,CACH,wEAAuEG,IAAI,CAACC,SAAL,CACtET,MAAM,CAACE,OAD+D,EAEtE,IAFsE,EAGtE,CAHsE,CAItE,EALE,CAAN;AAOD;;AACD,aAAO,EACL,GAAGH,KADE;AAELF,QAAAA,OAAO,EAAE,EACP,GAAGE,KAAK,CAACF,OADF;AAEP,WAACG,MAAM,CAACG,MAAP,CAAcC,IAAf,GAAsBE,gBAAEI,KAAF,CACpB,EADoB,EAEpBX,KAAK,CAACF,OAAN,CAAcG,MAAM,CAACG,MAAP,CAAcC,IAA5B,CAFoB,EAGpBJ,MAAM,CAACE,OAHa;AAFf;AAFJ,OAAP;;AAWF,SAAM,aAAN;AACEH,MAAAA,KAAK,CAACH,iBAAN,GAA0BI,MAAM,CAACE,OAAP,CAAeS,QAAf,CAAwBC,OAAlD;AACA,aAAOb,KAAP;;AACF;AACE,aAAOA,KAAP;AApCJ;AAsCD,CA1CM","sourcesContent":["import _ from \"lodash\"\nimport { ActionsUnion, IGatsbyState } from \"../types\"\n\nconst defaultState: IGatsbyState[\"status\"] = {\n PLUGINS_HASH: ``,\n LAST_NODE_COUNTER: 0,\n plugins: {},\n}\n\nexport const statusReducer = (\n state: IGatsbyState[\"status\"] = defaultState,\n action: ActionsUnion\n): IGatsbyState[\"status\"] => {\n switch (action.type) {\n case `DELETE_CACHE`:\n return defaultState\n case `UPDATE_PLUGINS_HASH`:\n return {\n ...state,\n PLUGINS_HASH: action.payload,\n }\n case `SET_PLUGIN_STATUS`:\n if (!action.plugin || !action.plugin?.name) {\n throw new Error(`You can't set plugin status without a plugin`)\n }\n if (!_.isObject(action.payload)) {\n throw new Error(\n `You must pass an object into setPluginStatus. What was passed in was ${JSON.stringify(\n action.payload,\n null,\n 4\n )}`\n )\n }\n return {\n ...state,\n plugins: {\n ...state.plugins,\n [action.plugin.name]: _.merge(\n {},\n state.plugins[action.plugin.name],\n action.payload\n ),\n },\n }\n case `CREATE_NODE`:\n state.LAST_NODE_COUNTER = action.payload.internal.counter\n return state\n default:\n return state\n }\n}\n"],"file":"status.js"}
|
package/dist/redux/types.d.ts
CHANGED
package/dist/redux/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/redux/types.ts"],"names":["ProgramStatus"],"mappings":";;;;IAqBYA,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a","sourcesContent":["import { IProgram } from \"../commands/types\"\nimport { GraphQLFieldExtensionDefinition } from \"../schema/extensions\"\nimport { DocumentNode, GraphQLSchema, DefinitionNode } from \"graphql\"\nimport { SchemaComposer } from \"graphql-compose\"\nimport { IGatsbyCLIState } from \"gatsby-cli/src/reporter/redux/types\"\nimport { InternalJob, JobResultInterface } from \"../utils/jobs-manager\"\nimport { ITypeMetadata } from \"../schema/infer/inference-metadata\"\n\ntype SystemPath = string\ntype Identifier = string\n\nexport interface IRedirect {\n fromPath: string\n toPath: string\n isPermanent?: boolean\n redirectInBrowser?: boolean\n ignoreCase: boolean\n // Users can add anything to this createRedirect API\n [key: string]: any\n}\n\nexport enum ProgramStatus {\n BOOTSTRAP_FINISHED = `BOOTSTRAP_FINISHED`,\n BOOTSTRAP_QUERY_RUNNING_FINISHED = `BOOTSTRAP_QUERY_RUNNING_FINISHED`,\n}\n\nexport interface IGatsbyPage {\n internalComponentName: string\n path: string\n matchPath: undefined | string\n component: SystemPath\n componentChunkName: string\n isCreatedByStatefulCreatePages: boolean\n context: {}\n updatedAt: number\n pluginCreator___NODE: Identifier\n pluginCreatorId: Identifier\n componentPath: SystemPath\n}\n\nexport interface IGatsbyConfig {\n plugins?: Array<{\n // This is the name of the plugin like `gatsby-plugin-manifest\n resolve: string\n options: {\n [key: string]: unknown\n }\n }>\n siteMetadata?: {\n title?: string\n author?: string\n description?: string\n siteUrl?: string\n // siteMetadata is free form\n [key: string]: unknown\n }\n // @deprecated\n polyfill?: boolean\n developMiddleware?: any\n proxy?: any\n pathPrefix?: string\n mapping?: Record<string, string>\n}\n\nexport interface IGatsbyNode {\n id: Identifier\n parent: Identifier\n children: Array<Identifier>\n internal: {\n type: string\n counter: number\n owner: string\n contentDigest: string\n mediaType?: string\n content?: string\n description?: string\n }\n __gatsby_resolved: any // TODO\n [key: string]: unknown\n fields: Array<string>\n}\n\nexport interface IGatsbyPlugin {\n id: Identifier\n name: string\n version: string\n [key: string]: any\n}\n\nexport interface IGatsbyPluginContext {\n [key: string]: (...args: Array<any>) => any\n}\n\nexport interface IGatsbyStaticQueryComponents {\n name: string\n componentPath: SystemPath\n id: Identifier\n query: string\n hash: string\n}\nexport interface IDefinitionMeta {\n name: string\n def: DefinitionNode\n filePath: string\n text: string\n templateLoc: any\n printedAst: string\n isHook: boolean\n isStaticQuery: boolean\n isFragment: boolean\n hash: string\n}\n\ntype GatsbyNodes = Map<string, IGatsbyNode>\n\nexport interface IGatsbyIncompleteJobV2 {\n job: InternalJob\n plugin: IGatsbyPlugin\n}\n\nexport interface IGatsbyIncompleteJob {\n job: InternalJob\n plugin: IGatsbyPlugin\n}\n\nexport interface IGatsbyCompleteJobV2 {\n result: JobResultInterface\n inputPaths: InternalJob[\"inputPaths\"]\n}\n\nexport interface IPlugin {\n name: string\n options: Record<string, any>\n}\n\nexport interface IBabelStage {\n plugins: Array<IPlugin>\n presets: Array<IPlugin>\n options: {\n cacheDirectory: boolean\n sourceType: string\n sourceMaps?: string\n }\n}\n\ntype BabelStageKeys =\n | \"develop\"\n | \"develop-html\"\n | \"build-html\"\n | \"build-javascript\"\n\nexport interface IStateProgram extends IProgram {\n extensions: Array<string>\n}\n\nexport interface IQueryState {\n dirty: number\n running: number\n}\n\nexport interface IComponentState {\n componentPath: string\n query: string\n pages: Set<Identifier>\n errors: number\n}\n\nexport type GatsbyNodeAPI =\n | \"onPreBoostrap\"\n | \"onPostBoostrap\"\n | \"onCreateWebpackConfig\"\n | \"onCreatePage\"\n | \"sourceNodes\"\n | \"createPagesStatefully\"\n | \"createPages\"\n | \"onPostBuild\"\n\nexport interface IGatsbyState {\n program: IStateProgram\n nodes: GatsbyNodes\n nodesByType: Map<string, GatsbyNodes>\n resolvedNodesCache: Map<string, any> // TODO\n nodesTouched: Set<string>\n lastAction: ActionsUnion\n flattenedPlugins: Array<{\n resolve: SystemPath\n id: Identifier\n name: string\n version: string\n pluginOptions: {\n plugins: []\n [key: string]: unknown\n }\n nodeAPIs: Array<GatsbyNodeAPI>\n browserAPIs: Array<\n | \"onRouteUpdate\"\n | \"registerServiceWorker\"\n | \"onServiceWorkerActive\"\n | \"onPostPrefetchPathname\"\n >\n ssrAPIs: Array<\"onRenderBody\" | \"onPreRenderHTML\">\n pluginFilepath: SystemPath\n }>\n config: IGatsbyConfig\n pages: Map<string, IGatsbyPage>\n schema: GraphQLSchema\n definitions: Map<string, IDefinitionMeta>\n status: {\n plugins: Record<string, IGatsbyPlugin>\n PLUGINS_HASH: Identifier\n }\n queries: {\n byNode: Map<Identifier, Set<Identifier>>\n byConnection: Map<string, Set<Identifier>>\n queryNodes: Map<Identifier, Set<Identifier>>\n trackedQueries: Map<Identifier, IQueryState>\n trackedComponents: Map<string, IComponentState>\n deletedQueries: Set<Identifier>\n dirtyQueriesListToEmitViaWebsocket: Array<string>\n }\n components: Map<\n SystemPath,\n {\n componentPath: SystemPath\n query: string\n pages: Set<string>\n isInBootstrap: boolean\n }\n >\n staticQueryComponents: Map<\n IGatsbyStaticQueryComponents[\"id\"],\n IGatsbyStaticQueryComponents\n >\n staticQueriesByTemplate: Map<SystemPath, Array<Identifier>>\n pendingPageDataWrites: {\n pagePaths: Set<string>\n }\n // @deprecated\n jobs: {\n active: Array<any> // TODO\n done: Array<any> // TODO\n }\n jobsV2: {\n incomplete: Map<Identifier, IGatsbyIncompleteJobV2>\n complete: Map<Identifier, IGatsbyCompleteJobV2>\n }\n webpack: any // TODO This should be the output from ./utils/webpack.config.js\n webpackCompilationHash: string\n redirects: Array<IRedirect>\n babelrc: {\n stages: {\n [key in BabelStageKeys]: IBabelStage\n }\n }\n schemaCustomization: {\n composer: null | SchemaComposer<any>\n context: Record<string, any>\n fieldExtensions: GraphQLFieldExtensionDefinition\n printConfig: {\n path?: string\n include?: { types?: Array<string>; plugins?: Array<string> }\n exclude?: { types?: Array<string>; plugins?: Array<string> }\n withFieldTypes?: boolean\n } | null\n thirdPartySchemas: Array<GraphQLSchema>\n types: Array<\n string | { typeOrTypeDef: DocumentNode; plugin: IGatsbyPlugin }\n >\n }\n themes: any // TODO\n logs: IGatsbyCLIState\n inferenceMetadata: {\n step: string // TODO make enum or union\n typeMap: {\n [key: string]: ITypeMetadata\n }\n }\n pageDataStats: Map<SystemPath, number>\n pageData: Map<Identifier, string>\n visitedPages: Map<string, Set<string>>\n}\n\nexport interface ICachedReduxState {\n nodes?: IGatsbyState[\"nodes\"]\n status: IGatsbyState[\"status\"]\n components: IGatsbyState[\"components\"]\n jobsV2: IGatsbyState[\"jobsV2\"]\n staticQueryComponents: IGatsbyState[\"staticQueryComponents\"]\n webpackCompilationHash: IGatsbyState[\"webpackCompilationHash\"]\n pageDataStats: IGatsbyState[\"pageDataStats\"]\n pageData: IGatsbyState[\"pageData\"]\n staticQueriesByTemplate: IGatsbyState[\"staticQueriesByTemplate\"]\n pendingPageDataWrites: IGatsbyState[\"pendingPageDataWrites\"]\n queries: IGatsbyState[\"queries\"]\n}\n\nexport type ActionsUnion =\n | IAddChildNodeToParentNodeAction\n | IAddFieldToNodeAction\n | IAddThirdPartySchema\n | IApiFinishedAction\n | ICreateFieldExtension\n | ICreateNodeAction\n | ICreatePageAction\n | ICreatePageDependencyAction\n | ICreateTypes\n | IDeleteCacheAction\n | IDeleteNodeAction\n | IDeleteNodesAction\n | IDeletePageAction\n | IPageQueryRunAction\n | IPrintTypeDefinitions\n | IQueryClearDirtyQueriesListToEmitViaWebsocket\n | IQueryExtractedAction\n | IQueryExtractedBabelSuccessAction\n | IQueryExtractionBabelErrorAction\n | IQueryExtractionGraphQLErrorAction\n | IQueryStartAction\n | IRemoveStaticQuery\n | IReplaceComponentQueryAction\n | IReplaceStaticQueryAction\n | IReplaceWebpackConfigAction\n | ISetPluginStatusAction\n | ISetProgramStatusAction\n | ISetResolvedNodesAction\n | ISetSchemaAction\n | ISetGraphQLDefinitionsAction\n | ISetSiteFlattenedPluginsAction\n | ISetWebpackCompilationHashAction\n | ISetWebpackConfigAction\n | ITouchNodeAction\n | IUpdatePluginsHashAction\n | IRemovePageDataAction\n | ISetPageDataAction\n | ICreateJobV2Action\n | IEndJobV2Action\n | IRemoveStaleJobV2Action\n | IAddPageDataStatsAction\n | IRemoveTemplateComponentAction\n | ISetBabelPluginAction\n | ISetBabelPresetAction\n | ISetBabelOptionsAction\n | ICreateJobAction\n | ISetJobAction\n | IEndJobAction\n | ISetStaticQueriesByTemplateAction\n | IAddPendingPageDataWriteAction\n | IAddPendingTemplateDataWriteAction\n | IClearPendingPageDataWriteAction\n | ICreateResolverContext\n | IClearSchemaCustomizationAction\n | ISetSchemaComposerAction\n | IStartIncrementalInferenceAction\n | IBuildTypeMetadataAction\n | IDisableTypeInferenceAction\n | ISetProgramAction\n | ISetProgramExtensions\n\nexport interface IApiFinishedAction {\n type: `API_FINISHED`\n payload: {\n apiName: GatsbyNodeAPI\n }\n}\n\ninterface ISetBabelPluginAction {\n type: `SET_BABEL_PLUGIN`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\ninterface ISetBabelPresetAction {\n type: `SET_BABEL_PRESET`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\ninterface ISetBabelOptionsAction {\n type: `SET_BABEL_OPTIONS`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\nexport interface ICreateJobV2Action {\n type: `CREATE_JOB_V2`\n payload: {\n job: IGatsbyIncompleteJobV2[\"job\"]\n plugin: IGatsbyIncompleteJobV2[\"plugin\"]\n }\n}\n\nexport interface IEndJobV2Action {\n type: `END_JOB_V2`\n payload: {\n jobContentDigest: string\n result: JobResultInterface\n }\n}\n\nexport interface IRemoveStaleJobV2Action {\n type: `REMOVE_STALE_JOB_V2`\n payload: {\n contentDigest: string\n }\n}\n\ninterface ICreateJobAction {\n type: `CREATE_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\ninterface ISetJobAction {\n type: `SET_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\ninterface IEndJobAction {\n type: `END_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\nexport interface ICreatePageDependencyAction {\n type: `CREATE_COMPONENT_DEPENDENCY`\n plugin?: string\n payload: {\n path: string\n nodeId?: string\n connection?: string\n }\n}\n\nexport interface IDeleteComponentDependenciesAction {\n type: \"DELETE_COMPONENTS_DEPENDENCIES\"\n payload: {\n paths: Array<string>\n }\n}\n\nexport interface IReplaceComponentQueryAction {\n type: \"REPLACE_COMPONENT_QUERY\"\n payload: {\n query: string\n componentPath: string\n }\n}\n\nexport interface IReplaceStaticQueryAction {\n type: `REPLACE_STATIC_QUERY`\n plugin: IGatsbyPlugin | null | undefined\n payload: {\n name: string\n componentPath: string\n id: string\n query: string\n hash: string\n }\n}\n\nexport interface IQueryClearDirtyQueriesListToEmitViaWebsocket {\n type: `QUERY_CLEAR_DIRTY_QUERIES_LIST_TO_EMIT_VIA_WEBSOCKET`\n}\n\nexport interface IQueryExtractedAction {\n type: `QUERY_EXTRACTED`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string; query: string }\n}\n\nexport interface IQueryExtractionGraphQLErrorAction {\n type: `QUERY_EXTRACTION_GRAPHQL_ERROR`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string; error: string }\n}\n\nexport interface IQueryExtractedBabelSuccessAction {\n type: `QUERY_EXTRACTION_BABEL_SUCCESS`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string }\n}\n\nexport interface IQueryExtractionBabelErrorAction {\n type: `QUERY_EXTRACTION_BABEL_ERROR`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: {\n componentPath: string\n error: Error\n }\n}\n\nexport interface ISetProgramStatusAction {\n type: `SET_PROGRAM_STATUS`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: ProgramStatus\n}\n\nexport interface IPageQueryRunAction {\n type: `PAGE_QUERY_RUN`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: {\n path: string\n componentPath: string\n isPage: boolean\n }\n}\n\nexport interface IQueryStartAction {\n type: `QUERY_START`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { path: string; componentPath: string; isPage: boolean }\n}\n\nexport interface IRemoveStaleJobAction {\n type: `REMOVE_STALE_JOB_V2`\n plugin: IGatsbyPlugin | undefined\n traceId?: string\n payload: { contentDigest: string }\n}\n\nexport interface IAddThirdPartySchema {\n type: `ADD_THIRD_PARTY_SCHEMA`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: GraphQLSchema\n}\n\nexport interface ICreateTypes {\n type: `CREATE_TYPES`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: DocumentNode | Array<DocumentNode>\n}\n\nexport interface ICreateFieldExtension {\n type: `CREATE_FIELD_EXTENSION`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: {\n name: string\n extension: GraphQLFieldExtensionDefinition\n }\n}\n\nexport interface IPrintTypeDefinitions {\n type: `PRINT_SCHEMA_REQUESTED`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: {\n path?: string\n include?: { types?: Array<string>; plugins?: Array<string> }\n exclude?: { types?: Array<string>; plugins?: Array<string> }\n withFieldTypes?: boolean\n }\n}\n\nexport interface ICreateResolverContext {\n type: `CREATE_RESOLVER_CONTEXT`\n plugin: IGatsbyPlugin\n traceId?: string\n payload:\n | IGatsbyPluginContext\n | { [camelCasedPluginNameWithoutPrefix: string]: IGatsbyPluginContext }\n}\n\ninterface IClearSchemaCustomizationAction {\n type: `CLEAR_SCHEMA_CUSTOMIZATION`\n}\n\ninterface ISetSchemaComposerAction {\n type: `SET_SCHEMA_COMPOSER`\n payload: SchemaComposer<any>\n}\n\nexport interface ICreateServerVisitedPage {\n type: `CREATE_SERVER_VISITED_PAGE`\n payload: IGatsbyPage\n plugin?: IGatsbyPlugin\n}\n\nexport interface ICreatePageAction {\n type: `CREATE_PAGE`\n payload: IGatsbyPage\n plugin?: IGatsbyPlugin\n contextModified?: boolean\n}\n\nexport interface ICreateRedirectAction {\n type: `CREATE_REDIRECT`\n payload: IRedirect\n}\n\nexport interface ISetResolvedThemesAction {\n type: `SET_RESOLVED_THEMES`\n payload: any // TODO\n}\n\nexport interface IDeleteCacheAction {\n type: `DELETE_CACHE`\n cacheIsCorrupt?: boolean\n}\n\nexport interface IRemovePageDataAction {\n type: `REMOVE_PAGE_DATA`\n payload: {\n id: Identifier\n }\n}\n\nexport interface ISetPageDataAction {\n type: `SET_PAGE_DATA`\n payload: {\n id: Identifier\n resultHash: string\n }\n}\n\nexport interface IRemoveTemplateComponentAction {\n type: `REMOVE_STATIC_QUERIES_BY_TEMPLATE`\n payload: {\n componentPath: string\n }\n}\n\nexport interface ISetStaticQueriesByTemplateAction {\n type: `SET_STATIC_QUERIES_BY_TEMPLATE`\n payload: {\n componentPath: string\n staticQueryHashes: Array<Identifier>\n }\n}\n\nexport interface IAddPendingPageDataWriteAction {\n type: `ADD_PENDING_PAGE_DATA_WRITE`\n payload: {\n path: string\n }\n}\n\nexport interface IAddPendingTemplateDataWriteAction {\n type: `ADD_PENDING_TEMPLATE_DATA_WRITE`\n payload: {\n componentPath: SystemPath\n pages: Array<string>\n }\n}\n\nexport interface IClearPendingPageDataWriteAction {\n type: `CLEAR_PENDING_PAGE_DATA_WRITE`\n payload: {\n page: string\n }\n}\n\nexport interface IDeletePageAction {\n type: `DELETE_PAGE`\n payload: IGatsbyPage\n}\n\nexport interface IReplaceStaticQueryAction {\n type: `REPLACE_STATIC_QUERY`\n payload: IGatsbyStaticQueryComponents\n}\n\nexport interface IRemoveStaticQuery {\n type: `REMOVE_STATIC_QUERY`\n payload: IGatsbyStaticQueryComponents[\"id\"]\n}\n\nexport interface ISetWebpackCompilationHashAction {\n type: `SET_WEBPACK_COMPILATION_HASH`\n payload: IGatsbyState[\"webpackCompilationHash\"]\n}\n\nexport interface IUpdatePluginsHashAction {\n type: `UPDATE_PLUGINS_HASH`\n payload: Identifier\n}\n\nexport interface ISetPluginStatusAction {\n type: `SET_PLUGIN_STATUS`\n plugin: IGatsbyPlugin\n payload: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n }\n}\n\nexport interface IReplaceWebpackConfigAction {\n type: `REPLACE_WEBPACK_CONFIG`\n payload: IGatsbyState[\"webpack\"]\n}\n\nexport interface ISetWebpackConfigAction {\n type: `SET_WEBPACK_CONFIG`\n payload: Partial<IGatsbyState[\"webpack\"]>\n}\n\nexport interface ISetSchemaAction {\n type: `SET_SCHEMA`\n payload: IGatsbyState[\"schema\"]\n}\n\nexport interface ISetGraphQLDefinitionsAction {\n type: `SET_GRAPHQL_DEFINITIONS`\n payload: IGatsbyState[\"definitions\"]\n}\n\nexport interface ISetSiteConfig {\n type: `SET_SITE_CONFIG`\n payload: IGatsbyState[\"config\"]\n}\n\nexport interface ICreateNodeAction {\n type: `CREATE_NODE`\n payload: IGatsbyNode\n oldNode?: IGatsbyNode\n}\n\nexport interface IAddFieldToNodeAction {\n type: `ADD_FIELD_TO_NODE`\n payload: IGatsbyNode\n addedField: string\n}\n\nexport interface IAddChildNodeToParentNodeAction {\n type: `ADD_CHILD_NODE_TO_PARENT_NODE`\n payload: IGatsbyNode\n}\n\nexport interface IDeleteNodeAction {\n type: `DELETE_NODE`\n // FIXME: figure out why payload can be undefined here\n payload: IGatsbyNode | void\n}\n\nexport interface IDeleteNodesAction {\n type: `DELETE_NODES`\n payload: Array<Identifier>\n fullNodes: Array<IGatsbyNode>\n}\n\nexport interface ISetSiteFlattenedPluginsAction {\n type: `SET_SITE_FLATTENED_PLUGINS`\n payload: IGatsbyState[\"flattenedPlugins\"]\n}\n\nexport interface ISetResolvedNodesAction {\n type: `SET_RESOLVED_NODES`\n payload: {\n key: string\n nodes: IGatsbyState[\"resolvedNodesCache\"]\n }\n}\n\nexport interface IAddPageDataStatsAction {\n type: `ADD_PAGE_DATA_STATS`\n payload: {\n filePath: SystemPath\n size: number\n }\n}\n\nexport interface ITouchNodeAction {\n type: `TOUCH_NODE`\n payload: Identifier\n}\n\ninterface IStartIncrementalInferenceAction {\n type: `START_INCREMENTAL_INFERENCE`\n}\n\ninterface IBuildTypeMetadataAction {\n type: `BUILD_TYPE_METADATA`\n payload: {\n nodes: Array<IGatsbyNode>\n typeName: string\n }\n}\n\ninterface IDisableTypeInferenceAction {\n type: `DISABLE_TYPE_INFERENCE`\n payload: Array<string>\n}\n\ninterface ISetProgramAction {\n type: `SET_PROGRAM`\n payload: IStateProgram\n}\n\ninterface ISetProgramExtensions {\n type: `SET_PROGRAM_EXTENSIONS`\n payload: Array<string>\n}\n"],"file":"types.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/redux/types.ts"],"names":["ProgramStatus"],"mappings":";;;;IAqBYA,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a","sourcesContent":["import { IProgram } from \"../commands/types\"\nimport { GraphQLFieldExtensionDefinition } from \"../schema/extensions\"\nimport { DocumentNode, GraphQLSchema, DefinitionNode } from \"graphql\"\nimport { SchemaComposer } from \"graphql-compose\"\nimport { IGatsbyCLIState } from \"gatsby-cli/src/reporter/redux/types\"\nimport { InternalJob, JobResultInterface } from \"../utils/jobs-manager\"\nimport { ITypeMetadata } from \"../schema/infer/inference-metadata\"\n\ntype SystemPath = string\ntype Identifier = string\n\nexport interface IRedirect {\n fromPath: string\n toPath: string\n isPermanent?: boolean\n redirectInBrowser?: boolean\n ignoreCase: boolean\n // Users can add anything to this createRedirect API\n [key: string]: any\n}\n\nexport enum ProgramStatus {\n BOOTSTRAP_FINISHED = `BOOTSTRAP_FINISHED`,\n BOOTSTRAP_QUERY_RUNNING_FINISHED = `BOOTSTRAP_QUERY_RUNNING_FINISHED`,\n}\n\nexport interface IGatsbyPage {\n internalComponentName: string\n path: string\n matchPath: undefined | string\n component: SystemPath\n componentChunkName: string\n isCreatedByStatefulCreatePages: boolean\n context: {}\n updatedAt: number\n pluginCreator___NODE: Identifier\n pluginCreatorId: Identifier\n componentPath: SystemPath\n}\n\nexport interface IGatsbyConfig {\n plugins?: Array<{\n // This is the name of the plugin like `gatsby-plugin-manifest\n resolve: string\n options: {\n [key: string]: unknown\n }\n }>\n siteMetadata?: {\n title?: string\n author?: string\n description?: string\n siteUrl?: string\n // siteMetadata is free form\n [key: string]: unknown\n }\n // @deprecated\n polyfill?: boolean\n developMiddleware?: any\n proxy?: any\n pathPrefix?: string\n mapping?: Record<string, string>\n}\n\nexport interface IGatsbyNode {\n id: Identifier\n parent: Identifier\n children: Array<Identifier>\n internal: {\n type: string\n counter: number\n owner: string\n contentDigest: string\n mediaType?: string\n content?: string\n description?: string\n }\n __gatsby_resolved: any // TODO\n [key: string]: unknown\n fields: Array<string>\n}\n\nexport interface IGatsbyPlugin {\n id: Identifier\n name: string\n version: string\n [key: string]: any\n}\n\nexport interface IGatsbyPluginContext {\n [key: string]: (...args: Array<any>) => any\n}\n\nexport interface IGatsbyStaticQueryComponents {\n name: string\n componentPath: SystemPath\n id: Identifier\n query: string\n hash: string\n}\nexport interface IDefinitionMeta {\n name: string\n def: DefinitionNode\n filePath: string\n text: string\n templateLoc: any\n printedAst: string\n isHook: boolean\n isStaticQuery: boolean\n isFragment: boolean\n hash: string\n}\n\ntype GatsbyNodes = Map<string, IGatsbyNode>\n\nexport interface IGatsbyIncompleteJobV2 {\n job: InternalJob\n plugin: IGatsbyPlugin\n}\n\nexport interface IGatsbyIncompleteJob {\n job: InternalJob\n plugin: IGatsbyPlugin\n}\n\nexport interface IGatsbyCompleteJobV2 {\n result: JobResultInterface\n inputPaths: InternalJob[\"inputPaths\"]\n}\n\nexport interface IPlugin {\n name: string\n options: Record<string, any>\n}\n\nexport interface IBabelStage {\n plugins: Array<IPlugin>\n presets: Array<IPlugin>\n options: {\n cacheDirectory: boolean\n sourceType: string\n sourceMaps?: string\n }\n}\n\ntype BabelStageKeys =\n | \"develop\"\n | \"develop-html\"\n | \"build-html\"\n | \"build-javascript\"\n\nexport interface IStateProgram extends IProgram {\n extensions: Array<string>\n}\n\nexport interface IQueryState {\n dirty: number\n running: number\n}\n\nexport interface IComponentState {\n componentPath: string\n query: string\n pages: Set<Identifier>\n errors: number\n}\n\nexport type GatsbyNodeAPI =\n | \"onPreBoostrap\"\n | \"onPostBoostrap\"\n | \"onCreateWebpackConfig\"\n | \"onCreatePage\"\n | \"sourceNodes\"\n | \"createPagesStatefully\"\n | \"createPages\"\n | \"onPostBuild\"\n\nexport interface IGatsbyState {\n program: IStateProgram\n nodes: GatsbyNodes\n nodesByType: Map<string, GatsbyNodes>\n resolvedNodesCache: Map<string, any> // TODO\n nodesTouched: Set<string>\n lastAction: ActionsUnion\n flattenedPlugins: Array<{\n resolve: SystemPath\n id: Identifier\n name: string\n version: string\n pluginOptions: {\n plugins: []\n [key: string]: unknown\n }\n nodeAPIs: Array<GatsbyNodeAPI>\n browserAPIs: Array<\n | \"onRouteUpdate\"\n | \"registerServiceWorker\"\n | \"onServiceWorkerActive\"\n | \"onPostPrefetchPathname\"\n >\n ssrAPIs: Array<\"onRenderBody\" | \"onPreRenderHTML\">\n pluginFilepath: SystemPath\n }>\n config: IGatsbyConfig\n pages: Map<string, IGatsbyPage>\n schema: GraphQLSchema\n definitions: Map<string, IDefinitionMeta>\n status: {\n plugins: Record<string, IGatsbyPlugin>\n PLUGINS_HASH: Identifier\n LAST_NODE_COUNTER: number\n }\n queries: {\n byNode: Map<Identifier, Set<Identifier>>\n byConnection: Map<string, Set<Identifier>>\n queryNodes: Map<Identifier, Set<Identifier>>\n trackedQueries: Map<Identifier, IQueryState>\n trackedComponents: Map<string, IComponentState>\n deletedQueries: Set<Identifier>\n dirtyQueriesListToEmitViaWebsocket: Array<string>\n }\n components: Map<\n SystemPath,\n {\n componentPath: SystemPath\n query: string\n pages: Set<string>\n isInBootstrap: boolean\n }\n >\n staticQueryComponents: Map<\n IGatsbyStaticQueryComponents[\"id\"],\n IGatsbyStaticQueryComponents\n >\n staticQueriesByTemplate: Map<SystemPath, Array<Identifier>>\n pendingPageDataWrites: {\n pagePaths: Set<string>\n }\n // @deprecated\n jobs: {\n active: Array<any> // TODO\n done: Array<any> // TODO\n }\n jobsV2: {\n incomplete: Map<Identifier, IGatsbyIncompleteJobV2>\n complete: Map<Identifier, IGatsbyCompleteJobV2>\n }\n webpack: any // TODO This should be the output from ./utils/webpack.config.js\n webpackCompilationHash: string\n redirects: Array<IRedirect>\n babelrc: {\n stages: {\n [key in BabelStageKeys]: IBabelStage\n }\n }\n schemaCustomization: {\n composer: null | SchemaComposer<any>\n context: Record<string, any>\n fieldExtensions: GraphQLFieldExtensionDefinition\n printConfig: {\n path?: string\n include?: { types?: Array<string>; plugins?: Array<string> }\n exclude?: { types?: Array<string>; plugins?: Array<string> }\n withFieldTypes?: boolean\n } | null\n thirdPartySchemas: Array<GraphQLSchema>\n types: Array<\n string | { typeOrTypeDef: DocumentNode; plugin: IGatsbyPlugin }\n >\n }\n themes: any // TODO\n logs: IGatsbyCLIState\n inferenceMetadata: {\n step: string // TODO make enum or union\n typeMap: {\n [key: string]: ITypeMetadata\n }\n }\n pageDataStats: Map<SystemPath, number>\n pageData: Map<Identifier, string>\n visitedPages: Map<string, Set<string>>\n}\n\nexport interface ICachedReduxState {\n nodes?: IGatsbyState[\"nodes\"]\n status: IGatsbyState[\"status\"]\n components: IGatsbyState[\"components\"]\n jobsV2: IGatsbyState[\"jobsV2\"]\n staticQueryComponents: IGatsbyState[\"staticQueryComponents\"]\n webpackCompilationHash: IGatsbyState[\"webpackCompilationHash\"]\n pageDataStats: IGatsbyState[\"pageDataStats\"]\n pageData: IGatsbyState[\"pageData\"]\n staticQueriesByTemplate: IGatsbyState[\"staticQueriesByTemplate\"]\n pendingPageDataWrites: IGatsbyState[\"pendingPageDataWrites\"]\n queries: IGatsbyState[\"queries\"]\n}\n\nexport type ActionsUnion =\n | IAddChildNodeToParentNodeAction\n | IAddFieldToNodeAction\n | IAddThirdPartySchema\n | IApiFinishedAction\n | ICreateFieldExtension\n | ICreateNodeAction\n | ICreatePageAction\n | ICreatePageDependencyAction\n | ICreateTypes\n | IDeleteCacheAction\n | IDeleteNodeAction\n | IDeleteNodesAction\n | IDeletePageAction\n | IPageQueryRunAction\n | IPrintTypeDefinitions\n | IQueryClearDirtyQueriesListToEmitViaWebsocket\n | IQueryExtractedAction\n | IQueryExtractedBabelSuccessAction\n | IQueryExtractionBabelErrorAction\n | IQueryExtractionGraphQLErrorAction\n | IQueryStartAction\n | IRemoveStaticQuery\n | IReplaceComponentQueryAction\n | IReplaceStaticQueryAction\n | IReplaceWebpackConfigAction\n | ISetPluginStatusAction\n | ISetProgramStatusAction\n | ISetResolvedNodesAction\n | ISetSchemaAction\n | ISetGraphQLDefinitionsAction\n | ISetSiteFlattenedPluginsAction\n | ISetWebpackCompilationHashAction\n | ISetWebpackConfigAction\n | ITouchNodeAction\n | IUpdatePluginsHashAction\n | IRemovePageDataAction\n | ISetPageDataAction\n | ICreateJobV2Action\n | IEndJobV2Action\n | IRemoveStaleJobV2Action\n | IAddPageDataStatsAction\n | IRemoveTemplateComponentAction\n | ISetBabelPluginAction\n | ISetBabelPresetAction\n | ISetBabelOptionsAction\n | ICreateJobAction\n | ISetJobAction\n | IEndJobAction\n | ISetStaticQueriesByTemplateAction\n | IAddPendingPageDataWriteAction\n | IAddPendingTemplateDataWriteAction\n | IClearPendingPageDataWriteAction\n | ICreateResolverContext\n | IClearSchemaCustomizationAction\n | ISetSchemaComposerAction\n | IStartIncrementalInferenceAction\n | IBuildTypeMetadataAction\n | IDisableTypeInferenceAction\n | ISetProgramAction\n | ISetProgramExtensions\n\nexport interface IApiFinishedAction {\n type: `API_FINISHED`\n payload: {\n apiName: GatsbyNodeAPI\n }\n}\n\ninterface ISetBabelPluginAction {\n type: `SET_BABEL_PLUGIN`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\ninterface ISetBabelPresetAction {\n type: `SET_BABEL_PRESET`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\ninterface ISetBabelOptionsAction {\n type: `SET_BABEL_OPTIONS`\n payload: {\n stage: BabelStageKeys\n name: IPlugin[\"name\"]\n options: IPlugin[\"options\"]\n }\n}\n\nexport interface ICreateJobV2Action {\n type: `CREATE_JOB_V2`\n payload: {\n job: IGatsbyIncompleteJobV2[\"job\"]\n plugin: IGatsbyIncompleteJobV2[\"plugin\"]\n }\n}\n\nexport interface IEndJobV2Action {\n type: `END_JOB_V2`\n payload: {\n jobContentDigest: string\n result: JobResultInterface\n }\n}\n\nexport interface IRemoveStaleJobV2Action {\n type: `REMOVE_STALE_JOB_V2`\n payload: {\n contentDigest: string\n }\n}\n\ninterface ICreateJobAction {\n type: `CREATE_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\ninterface ISetJobAction {\n type: `SET_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\ninterface IEndJobAction {\n type: `END_JOB`\n payload: {\n id: string\n job: IGatsbyIncompleteJob[\"job\"]\n }\n plugin: IGatsbyIncompleteJob[\"plugin\"]\n}\n\nexport interface ICreatePageDependencyAction {\n type: `CREATE_COMPONENT_DEPENDENCY`\n plugin?: string\n payload: {\n path: string\n nodeId?: string\n connection?: string\n }\n}\n\nexport interface IDeleteComponentDependenciesAction {\n type: \"DELETE_COMPONENTS_DEPENDENCIES\"\n payload: {\n paths: Array<string>\n }\n}\n\nexport interface IReplaceComponentQueryAction {\n type: \"REPLACE_COMPONENT_QUERY\"\n payload: {\n query: string\n componentPath: string\n }\n}\n\nexport interface IReplaceStaticQueryAction {\n type: `REPLACE_STATIC_QUERY`\n plugin: IGatsbyPlugin | null | undefined\n payload: {\n name: string\n componentPath: string\n id: string\n query: string\n hash: string\n }\n}\n\nexport interface IQueryClearDirtyQueriesListToEmitViaWebsocket {\n type: `QUERY_CLEAR_DIRTY_QUERIES_LIST_TO_EMIT_VIA_WEBSOCKET`\n}\n\nexport interface IQueryExtractedAction {\n type: `QUERY_EXTRACTED`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string; query: string }\n}\n\nexport interface IQueryExtractionGraphQLErrorAction {\n type: `QUERY_EXTRACTION_GRAPHQL_ERROR`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string; error: string }\n}\n\nexport interface IQueryExtractedBabelSuccessAction {\n type: `QUERY_EXTRACTION_BABEL_SUCCESS`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { componentPath: string }\n}\n\nexport interface IQueryExtractionBabelErrorAction {\n type: `QUERY_EXTRACTION_BABEL_ERROR`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: {\n componentPath: string\n error: Error\n }\n}\n\nexport interface ISetProgramStatusAction {\n type: `SET_PROGRAM_STATUS`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: ProgramStatus\n}\n\nexport interface IPageQueryRunAction {\n type: `PAGE_QUERY_RUN`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: {\n path: string\n componentPath: string\n isPage: boolean\n }\n}\n\nexport interface IQueryStartAction {\n type: `QUERY_START`\n plugin: IGatsbyPlugin\n traceId: string | undefined\n payload: { path: string; componentPath: string; isPage: boolean }\n}\n\nexport interface IRemoveStaleJobAction {\n type: `REMOVE_STALE_JOB_V2`\n plugin: IGatsbyPlugin | undefined\n traceId?: string\n payload: { contentDigest: string }\n}\n\nexport interface IAddThirdPartySchema {\n type: `ADD_THIRD_PARTY_SCHEMA`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: GraphQLSchema\n}\n\nexport interface ICreateTypes {\n type: `CREATE_TYPES`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: DocumentNode | Array<DocumentNode>\n}\n\nexport interface ICreateFieldExtension {\n type: `CREATE_FIELD_EXTENSION`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: {\n name: string\n extension: GraphQLFieldExtensionDefinition\n }\n}\n\nexport interface IPrintTypeDefinitions {\n type: `PRINT_SCHEMA_REQUESTED`\n plugin: IGatsbyPlugin\n traceId?: string\n payload: {\n path?: string\n include?: { types?: Array<string>; plugins?: Array<string> }\n exclude?: { types?: Array<string>; plugins?: Array<string> }\n withFieldTypes?: boolean\n }\n}\n\nexport interface ICreateResolverContext {\n type: `CREATE_RESOLVER_CONTEXT`\n plugin: IGatsbyPlugin\n traceId?: string\n payload:\n | IGatsbyPluginContext\n | { [camelCasedPluginNameWithoutPrefix: string]: IGatsbyPluginContext }\n}\n\ninterface IClearSchemaCustomizationAction {\n type: `CLEAR_SCHEMA_CUSTOMIZATION`\n}\n\ninterface ISetSchemaComposerAction {\n type: `SET_SCHEMA_COMPOSER`\n payload: SchemaComposer<any>\n}\n\nexport interface ICreateServerVisitedPage {\n type: `CREATE_SERVER_VISITED_PAGE`\n payload: IGatsbyPage\n plugin?: IGatsbyPlugin\n}\n\nexport interface ICreatePageAction {\n type: `CREATE_PAGE`\n payload: IGatsbyPage\n plugin?: IGatsbyPlugin\n contextModified?: boolean\n}\n\nexport interface ICreateRedirectAction {\n type: `CREATE_REDIRECT`\n payload: IRedirect\n}\n\nexport interface ISetResolvedThemesAction {\n type: `SET_RESOLVED_THEMES`\n payload: any // TODO\n}\n\nexport interface IDeleteCacheAction {\n type: `DELETE_CACHE`\n cacheIsCorrupt?: boolean\n}\n\nexport interface IRemovePageDataAction {\n type: `REMOVE_PAGE_DATA`\n payload: {\n id: Identifier\n }\n}\n\nexport interface ISetPageDataAction {\n type: `SET_PAGE_DATA`\n payload: {\n id: Identifier\n resultHash: string\n }\n}\n\nexport interface IRemoveTemplateComponentAction {\n type: `REMOVE_STATIC_QUERIES_BY_TEMPLATE`\n payload: {\n componentPath: string\n }\n}\n\nexport interface ISetStaticQueriesByTemplateAction {\n type: `SET_STATIC_QUERIES_BY_TEMPLATE`\n payload: {\n componentPath: string\n staticQueryHashes: Array<Identifier>\n }\n}\n\nexport interface IAddPendingPageDataWriteAction {\n type: `ADD_PENDING_PAGE_DATA_WRITE`\n payload: {\n path: string\n }\n}\n\nexport interface IAddPendingTemplateDataWriteAction {\n type: `ADD_PENDING_TEMPLATE_DATA_WRITE`\n payload: {\n componentPath: SystemPath\n pages: Array<string>\n }\n}\n\nexport interface IClearPendingPageDataWriteAction {\n type: `CLEAR_PENDING_PAGE_DATA_WRITE`\n payload: {\n page: string\n }\n}\n\nexport interface IDeletePageAction {\n type: `DELETE_PAGE`\n payload: IGatsbyPage\n}\n\nexport interface IReplaceStaticQueryAction {\n type: `REPLACE_STATIC_QUERY`\n payload: IGatsbyStaticQueryComponents\n}\n\nexport interface IRemoveStaticQuery {\n type: `REMOVE_STATIC_QUERY`\n payload: IGatsbyStaticQueryComponents[\"id\"]\n}\n\nexport interface ISetWebpackCompilationHashAction {\n type: `SET_WEBPACK_COMPILATION_HASH`\n payload: IGatsbyState[\"webpackCompilationHash\"]\n}\n\nexport interface IUpdatePluginsHashAction {\n type: `UPDATE_PLUGINS_HASH`\n payload: Identifier\n}\n\nexport interface ISetPluginStatusAction {\n type: `SET_PLUGIN_STATUS`\n plugin: IGatsbyPlugin\n payload: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n }\n}\n\nexport interface IReplaceWebpackConfigAction {\n type: `REPLACE_WEBPACK_CONFIG`\n payload: IGatsbyState[\"webpack\"]\n}\n\nexport interface ISetWebpackConfigAction {\n type: `SET_WEBPACK_CONFIG`\n payload: Partial<IGatsbyState[\"webpack\"]>\n}\n\nexport interface ISetSchemaAction {\n type: `SET_SCHEMA`\n payload: IGatsbyState[\"schema\"]\n}\n\nexport interface ISetGraphQLDefinitionsAction {\n type: `SET_GRAPHQL_DEFINITIONS`\n payload: IGatsbyState[\"definitions\"]\n}\n\nexport interface ISetSiteConfig {\n type: `SET_SITE_CONFIG`\n payload: IGatsbyState[\"config\"]\n}\n\nexport interface ICreateNodeAction {\n type: `CREATE_NODE`\n payload: IGatsbyNode\n oldNode?: IGatsbyNode\n}\n\nexport interface IAddFieldToNodeAction {\n type: `ADD_FIELD_TO_NODE`\n payload: IGatsbyNode\n addedField: string\n}\n\nexport interface IAddChildNodeToParentNodeAction {\n type: `ADD_CHILD_NODE_TO_PARENT_NODE`\n payload: IGatsbyNode\n}\n\nexport interface IDeleteNodeAction {\n type: `DELETE_NODE`\n // FIXME: figure out why payload can be undefined here\n payload: IGatsbyNode | void\n}\n\nexport interface IDeleteNodesAction {\n type: `DELETE_NODES`\n payload: Array<Identifier>\n fullNodes: Array<IGatsbyNode>\n}\n\nexport interface ISetSiteFlattenedPluginsAction {\n type: `SET_SITE_FLATTENED_PLUGINS`\n payload: IGatsbyState[\"flattenedPlugins\"]\n}\n\nexport interface ISetResolvedNodesAction {\n type: `SET_RESOLVED_NODES`\n payload: {\n key: string\n nodes: IGatsbyState[\"resolvedNodesCache\"]\n }\n}\n\nexport interface IAddPageDataStatsAction {\n type: `ADD_PAGE_DATA_STATS`\n payload: {\n filePath: SystemPath\n size: number\n }\n}\n\nexport interface ITouchNodeAction {\n type: `TOUCH_NODE`\n payload: Identifier\n}\n\ninterface IStartIncrementalInferenceAction {\n type: `START_INCREMENTAL_INFERENCE`\n}\n\ninterface IBuildTypeMetadataAction {\n type: `BUILD_TYPE_METADATA`\n payload: {\n nodes: Array<IGatsbyNode>\n typeName: string\n }\n}\n\ninterface IDisableTypeInferenceAction {\n type: `DISABLE_TYPE_INFERENCE`\n payload: Array<string>\n}\n\ninterface ISetProgramAction {\n type: `SET_PROGRAM`\n payload: IStateProgram\n}\n\ninterface ISetProgramExtensions {\n type: `SET_PROGRAM_EXTENSIONS`\n payload: Array<string>\n}\n"],"file":"types.js"}
|
|
@@ -261,9 +261,7 @@ const developConfig = {
|
|
|
261
261
|
// We need to run mutations immediately when in this state
|
|
262
262
|
ADD_NODE_MUTATION: {
|
|
263
263
|
actions: `callApi`
|
|
264
|
-
}
|
|
265
|
-
// Ignore, because we're about to extract them anyway
|
|
266
|
-
SOURCE_FILE_CHANGED: undefined
|
|
264
|
+
}
|
|
267
265
|
},
|
|
268
266
|
invoke: {
|
|
269
267
|
src: `reloadData`,
|