From 29b1103f71987fba132f46993bf35e2f20054c8c Mon Sep 17 00:00:00 2001 From: Brent Jackson Date: Wed, 10 Apr 2019 20:21:36 -0400 Subject: [PATCH 01/24] Spike for gatsby theme --- packages/components/src/MDXDeck.js | 25 +- packages/components/src/Overview.js | 22 +- packages/components/src/index.js | 2 +- packages/components/src/mdx-components.js | 1 + packages/gatsby-theme/.cache/.eslintrc.json | 9 + .../gatsby-theme/.cache/__tests__/.babelrc | 5 + .../__snapshots__/static-entry.js.snap | 13 + .../.cache/__tests__/error-overlay-handler.js | 59 + .../.cache/__tests__/find-page.js | 67 + .../.cache/__tests__/minimal-config.js | 32 + .../.cache/__tests__/static-entry.js | 274 + .../.cache/__tests__/strip-prefix.js | 23 + .../.cache/api-runner-browser-plugins.js | 6 + .../gatsby-theme/.cache/api-runner-browser.js | 55 + .../gatsby-theme/.cache/api-runner-ssr.js | 48 + packages/gatsby-theme/.cache/api-ssr-docs.js | 181 + packages/gatsby-theme/.cache/app.js | 69 + .../gatsby-theme/.cache/async-requires.js | 16 + packages/gatsby-theme/.cache/babelState.json | 57 + ...tore-78682d9aeb406f36b6b09928aad04ebc.json | 84 + ...tore-9b107b685825a8d9ccf2be031e4d3ae3.json | 258 + ...tore-c15279c10aa984fadeb4921a3dbb6447.json | 249 + .../1970366a8c100bb8e42caab4bfa24659.js | 4 + .../commonjs/api-runner-browser-plugins.js | 15 + .../.cache/commonjs/api-runner-browser.js | 62 + .../.cache/commonjs/api-runner-ssr.js | 46 + .../.cache/commonjs/api-ssr-docs.js | 183 + packages/gatsby-theme/.cache/commonjs/app.js | 103 + .../.cache/commonjs/create-react-context.js | 11 + .../.cache/commonjs/default-html.js | 63 + .../.cache/commonjs/develop-static-entry.js | 136 + .../gatsby-theme/.cache/commonjs/emitter.js | 12 + .../.cache/commonjs/ensure-resources.js | 154 + .../.cache/commonjs/error-overlay-handler.js | 52 + .../gatsby-theme/.cache/commonjs/find-page.js | 61 + .../.cache/commonjs/gatsby-browser-entry.js | 98 + .../.cache/commonjs/json-store.js | 128 + .../gatsby-theme/.cache/commonjs/loader.js | 449 ++ .../.cache/commonjs/navigation.js | 199 + .../.cache/commonjs/page-renderer.js | 67 + .../gatsby-theme/.cache/commonjs/prefetch.js | 83 + .../.cache/commonjs/production-app.js | 168 + .../commonjs/public-page-renderer-dev.js | 36 + .../commonjs/public-page-renderer-prod.js | 39 + .../.cache/commonjs/public-page-renderer.js | 11 + .../commonjs/react-lifecycles-compat.js | 3 + .../commonjs/register-service-worker.js | 77 + packages/gatsby-theme/.cache/commonjs/root.js | 183 + .../gatsby-theme/.cache/commonjs/socketIo.js | 117 + .../.cache/commonjs/static-entry.js | 448 ++ .../.cache/commonjs/strip-prefix.js | 15 + .../.cache/create-react-context.js | 3 + packages/gatsby-theme/.cache/data.json | 34 + packages/gatsby-theme/.cache/default-html.js | 39 + packages/gatsby-theme/.cache/dev-404-page.js | 86 + .../.cache/develop-static-entry.js | 115 + packages/gatsby-theme/.cache/emitter.js | 4 + .../gatsby-theme/.cache/ensure-resources.js | 148 + .../.cache/error-overlay-handler.js | 41 + packages/gatsby-theme/.cache/find-page.js | 55 + .../.cache/gatsby-browser-entry.js | 83 + packages/gatsby-theme/.cache/json-store.js | 99 + packages/gatsby-theme/.cache/loader.js | 447 ++ packages/gatsby-theme/.cache/match-paths.json | 1 + packages/gatsby-theme/.cache/navigation.js | 164 + packages/gatsby-theme/.cache/page-renderer.js | 46 + packages/gatsby-theme/.cache/pages.json | 23 + packages/gatsby-theme/.cache/prefetch.js | 77 + .../gatsby-theme/.cache/production-app.js | 126 + .../.cache/public-page-renderer-dev.js | 23 + .../.cache/public-page-renderer-prod.js | 22 + .../.cache/public-page-renderer.js | 9 + .../.cache/react-lifecycles-compat.js | 1 + packages/gatsby-theme/.cache/redirects.json | 1 + packages/gatsby-theme/.cache/redux-state.json | 1038 ++++ .../.cache/register-service-worker.js | 64 + packages/gatsby-theme/.cache/root.js | 119 + packages/gatsby-theme/.cache/socketIo.js | 100 + packages/gatsby-theme/.cache/static-entry.js | 407 ++ packages/gatsby-theme/.cache/strip-prefix.js | 9 + packages/gatsby-theme/.cache/sync-requires.js | 27 + .../gatsby-theme/.cache/test-require-error.js | 20 + packages/gatsby-theme/gatsby-config.js | 29 + packages/gatsby-theme/gatsby-node.js | 80 + packages/gatsby-theme/package.json | 34 + packages/gatsby-theme/src/decks.js | 40 + packages/gatsby-theme/src/decks/hello.mdx | 31 + packages/gatsby-theme/src/index.js | 3 + packages/gatsby-theme/src/layout.js | 52 + packages/gatsby-theme/src/pages/index.mdx | 8 + packages/gatsby-theme/src/template.js | 21 + yarn.lock | 4989 ++++++++++++++++- 92 files changed, 13107 insertions(+), 189 deletions(-) create mode 100644 packages/gatsby-theme/.cache/.eslintrc.json create mode 100644 packages/gatsby-theme/.cache/__tests__/.babelrc create mode 100644 packages/gatsby-theme/.cache/__tests__/__snapshots__/static-entry.js.snap create mode 100644 packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js create mode 100644 packages/gatsby-theme/.cache/__tests__/find-page.js create mode 100644 packages/gatsby-theme/.cache/__tests__/minimal-config.js create mode 100644 packages/gatsby-theme/.cache/__tests__/static-entry.js create mode 100644 packages/gatsby-theme/.cache/__tests__/strip-prefix.js create mode 100644 packages/gatsby-theme/.cache/api-runner-browser-plugins.js create mode 100644 packages/gatsby-theme/.cache/api-runner-browser.js create mode 100644 packages/gatsby-theme/.cache/api-runner-ssr.js create mode 100644 packages/gatsby-theme/.cache/api-ssr-docs.js create mode 100644 packages/gatsby-theme/.cache/app.js create mode 100644 packages/gatsby-theme/.cache/async-requires.js create mode 100644 packages/gatsby-theme/.cache/babelState.json create mode 100644 packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json create mode 100644 packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json create mode 100644 packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json create mode 100644 packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js create mode 100644 packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js create mode 100644 packages/gatsby-theme/.cache/commonjs/api-runner-browser.js create mode 100644 packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js create mode 100644 packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js create mode 100644 packages/gatsby-theme/.cache/commonjs/app.js create mode 100644 packages/gatsby-theme/.cache/commonjs/create-react-context.js create mode 100644 packages/gatsby-theme/.cache/commonjs/default-html.js create mode 100644 packages/gatsby-theme/.cache/commonjs/develop-static-entry.js create mode 100644 packages/gatsby-theme/.cache/commonjs/emitter.js create mode 100644 packages/gatsby-theme/.cache/commonjs/ensure-resources.js create mode 100644 packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js create mode 100644 packages/gatsby-theme/.cache/commonjs/find-page.js create mode 100644 packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js create mode 100644 packages/gatsby-theme/.cache/commonjs/json-store.js create mode 100644 packages/gatsby-theme/.cache/commonjs/loader.js create mode 100644 packages/gatsby-theme/.cache/commonjs/navigation.js create mode 100644 packages/gatsby-theme/.cache/commonjs/page-renderer.js create mode 100644 packages/gatsby-theme/.cache/commonjs/prefetch.js create mode 100644 packages/gatsby-theme/.cache/commonjs/production-app.js create mode 100644 packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js create mode 100644 packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js create mode 100644 packages/gatsby-theme/.cache/commonjs/public-page-renderer.js create mode 100644 packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js create mode 100644 packages/gatsby-theme/.cache/commonjs/register-service-worker.js create mode 100644 packages/gatsby-theme/.cache/commonjs/root.js create mode 100644 packages/gatsby-theme/.cache/commonjs/socketIo.js create mode 100644 packages/gatsby-theme/.cache/commonjs/static-entry.js create mode 100644 packages/gatsby-theme/.cache/commonjs/strip-prefix.js create mode 100644 packages/gatsby-theme/.cache/create-react-context.js create mode 100644 packages/gatsby-theme/.cache/data.json create mode 100644 packages/gatsby-theme/.cache/default-html.js create mode 100644 packages/gatsby-theme/.cache/dev-404-page.js create mode 100644 packages/gatsby-theme/.cache/develop-static-entry.js create mode 100644 packages/gatsby-theme/.cache/emitter.js create mode 100644 packages/gatsby-theme/.cache/ensure-resources.js create mode 100644 packages/gatsby-theme/.cache/error-overlay-handler.js create mode 100644 packages/gatsby-theme/.cache/find-page.js create mode 100644 packages/gatsby-theme/.cache/gatsby-browser-entry.js create mode 100644 packages/gatsby-theme/.cache/json-store.js create mode 100644 packages/gatsby-theme/.cache/loader.js create mode 100644 packages/gatsby-theme/.cache/match-paths.json create mode 100644 packages/gatsby-theme/.cache/navigation.js create mode 100644 packages/gatsby-theme/.cache/page-renderer.js create mode 100644 packages/gatsby-theme/.cache/pages.json create mode 100644 packages/gatsby-theme/.cache/prefetch.js create mode 100644 packages/gatsby-theme/.cache/production-app.js create mode 100644 packages/gatsby-theme/.cache/public-page-renderer-dev.js create mode 100644 packages/gatsby-theme/.cache/public-page-renderer-prod.js create mode 100644 packages/gatsby-theme/.cache/public-page-renderer.js create mode 100644 packages/gatsby-theme/.cache/react-lifecycles-compat.js create mode 100644 packages/gatsby-theme/.cache/redirects.json create mode 100644 packages/gatsby-theme/.cache/redux-state.json create mode 100644 packages/gatsby-theme/.cache/register-service-worker.js create mode 100644 packages/gatsby-theme/.cache/root.js create mode 100644 packages/gatsby-theme/.cache/socketIo.js create mode 100644 packages/gatsby-theme/.cache/static-entry.js create mode 100644 packages/gatsby-theme/.cache/strip-prefix.js create mode 100644 packages/gatsby-theme/.cache/sync-requires.js create mode 100644 packages/gatsby-theme/.cache/test-require-error.js create mode 100644 packages/gatsby-theme/gatsby-config.js create mode 100644 packages/gatsby-theme/gatsby-node.js create mode 100644 packages/gatsby-theme/package.json create mode 100644 packages/gatsby-theme/src/decks.js create mode 100644 packages/gatsby-theme/src/decks/hello.mdx create mode 100644 packages/gatsby-theme/src/index.js create mode 100644 packages/gatsby-theme/src/layout.js create mode 100644 packages/gatsby-theme/src/pages/index.mdx create mode 100644 packages/gatsby-theme/src/template.js diff --git a/packages/components/src/MDXDeck.js b/packages/components/src/MDXDeck.js index 2a1993f..e40a7c3 100644 --- a/packages/components/src/MDXDeck.js +++ b/packages/components/src/MDXDeck.js @@ -102,8 +102,10 @@ export class MDXDeck extends React.Component { } getIndex = () => { + const { basepath } = this.props const { pathname } = globalHistory.location - return Number(pathname.split('/')[1] || 0) + const pagepath = pathname.replace(basepath, '') + return Number(pagepath.split('/')[1] || 0) } getMeta = i => { @@ -113,9 +115,10 @@ export class MDXDeck extends React.Component { } goto = i => { + const { basepath } = this.props const current = this.getIndex() const reverse = i < current - navigate('/' + i) + navigate(basepath + '/' + i) const meta = this.getMeta(i) this.setState({ step: reverse ? meta.steps || 0 : 0, @@ -194,13 +197,16 @@ export class MDXDeck extends React.Component { componentDidUpdate() { const index = this.getIndex() const { step, mode } = this.state + const { pathname, search } = globalHistory.location localStorage.setItem(STORAGE_INDEX, index) localStorage.setItem(STORAGE_STEP, step) + if (mode !== NORMAL && mode !== PRINT) { const query = '?' + querystring.stringify({ mode }) + if (query === search) return navigate(query) } else { - const { pathname } = globalHistory.location + if (!search) return navigate(pathname) } } @@ -211,6 +217,7 @@ export class MDXDeck extends React.Component { } render() { + const { basepath } = this.props const { pathname } = globalHistory.location const { slides } = this.state const mode = pathname === '/print' ? PRINT : this.state.mode @@ -240,18 +247,19 @@ export class MDXDeck extends React.Component { - + - - - + + + + {slides.map((Component, i) => ( ))} - + @@ -267,6 +275,7 @@ MDXDeck.propTypes = { } MDXDeck.defaultProps = { + basepath: '', slides: [], headTags: [], } diff --git a/packages/components/src/Overview.js b/packages/components/src/Overview.js index bda6625..994f83a 100644 --- a/packages/components/src/Overview.js +++ b/packages/components/src/Overview.js @@ -1,23 +1,11 @@ import React, { useEffect } from 'react' -import { Location, navigate } from '@reach/router' +import { navigate } from '@reach/router' import Zoom from './Zoom' import Slide from './Slide' import Pre from './Pre' -const getIndex = ({ pathname }) => { - return Number(pathname.split('/')[1] || 0) -} - -const withLocation = Component => props => ( - ( - - )} - /> -) - -export const Overview = withLocation(props => { - const { index, slides } = props +export const Overview = props => { + const { index, slides, basepath } = props const activeThumb = React.createRef() useEffect(() => { @@ -54,7 +42,7 @@ export const Overview = withLocation(props => { key={i} role="link" onClick={e => { - navigate('/' + i) + navigate(basepath + '/' + i) }} style={{ display: 'block', @@ -88,6 +76,6 @@ export const Overview = withLocation(props => { ) -}) +} export default Overview diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 1aa8847..e424a28 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -5,4 +5,4 @@ export { Notes } from './Notes' export { Steps } from './Steps' export { Appear } from './Appear' export { withContext, useDeck } from './context' -export useSteps from './useSteps' +export { default as useSteps } from './useSteps' diff --git a/packages/components/src/mdx-components.js b/packages/components/src/mdx-components.js index 1362bb8..c509d76 100644 --- a/packages/components/src/mdx-components.js +++ b/packages/components/src/mdx-components.js @@ -46,6 +46,7 @@ export const table = props => ( ) export const components = { + wrapper: props => props.children, pre: props => props.children, code, inlineCode, diff --git a/packages/gatsby-theme/.cache/.eslintrc.json b/packages/gatsby-theme/.cache/.eslintrc.json new file mode 100644 index 0000000..7396d0e --- /dev/null +++ b/packages/gatsby-theme/.cache/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "env": { + "browser": true + }, + "globals": { + "__PATH_PREFIX__": false, + "___emitter": false + } +} diff --git a/packages/gatsby-theme/.cache/__tests__/.babelrc b/packages/gatsby-theme/.cache/__tests__/.babelrc new file mode 100644 index 0000000..b1ff77b --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + ["babel-preset-gatsby"] + ] +} diff --git a/packages/gatsby-theme/.cache/__tests__/__snapshots__/static-entry.js.snap b/packages/gatsby-theme/.cache/__tests__/__snapshots__/static-entry.js.snap new file mode 100644 index 0000000..2137dd0 --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/__snapshots__/static-entry.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`develop-static-entry onPreRenderHTML can be used to replace headComponents 1`] = `"
"`; + +exports[`develop-static-entry onPreRenderHTML can be used to replace postBodyComponents 1`] = `"
div3
div2
div1
"`; + +exports[`develop-static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`; + +exports[`static-entry onPreRenderHTML can be used to replace headComponents 1`] = `"
"`; + +exports[`static-entry onPreRenderHTML can be used to replace postBodyComponents 1`] = `"
div3
div2
div1
"`; + +exports[`static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`; diff --git a/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js b/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js new file mode 100644 index 0000000..f082280 --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js @@ -0,0 +1,59 @@ +import '@babel/polyfill' +const { + reportError, + clearError, + errorMap, +} = require(`../error-overlay-handler`) + +import * as ErrorOverlay from 'react-error-overlay' + +jest.mock(`react-error-overlay`, () => { + return { + reportBuildError: jest.fn(), + dismissBuildError: jest.fn(), + startReportingRuntimeErrors: jest.fn(), + setEditorHandler: jest.fn(), + } +}) + +beforeEach(() => { + ErrorOverlay.reportBuildError.mockClear() + ErrorOverlay.dismissBuildError.mockClear() +}) + +describe(`errorOverlayHandler`, () => { + describe(`clearError()`, () => { + beforeEach(() => { + reportError(`foo`, `error`) + reportError(`bar`, `error`) + }) + afterAll(() => { + clearError(`foo`) + clearError(`bar`) + }) + it(`should clear specific error type`, () => { + expect(Object.keys(errorMap)).toHaveLength(2) + clearError(`foo`) + expect(Object.keys(errorMap)).toHaveLength(1) + expect(ErrorOverlay.dismissBuildError).not.toHaveBeenCalled() + }) + + it(`should call ErrorOverlay to dismiss build errors`, () => { + clearError(`foo`) + clearError(`bar`) + expect(ErrorOverlay.dismissBuildError).toHaveBeenCalled() + }) + }) + describe(`reportErrorOverlay()`, () => { + it(`should not add error if it's empty and not call ErrorOverlay`, () => { + reportError(`foo`, null) + expect(Object.keys(errorMap)).toHaveLength(0) + expect(ErrorOverlay.reportBuildError).not.toHaveBeenCalled() + }) + it(`should add error if it has a truthy value and call ErrorOverlay`, () => { + reportError(`foo`, `bar`) + expect(Object.keys(errorMap)).toHaveLength(1) + expect(ErrorOverlay.reportBuildError).toHaveBeenCalled() + }) + }) +}) diff --git a/packages/gatsby-theme/.cache/__tests__/find-page.js b/packages/gatsby-theme/.cache/__tests__/find-page.js new file mode 100644 index 0000000..c998b8e --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/find-page.js @@ -0,0 +1,67 @@ +const pageFinderFactory = require(`../find-page`).default + +let findPage + +describe(`find-page`, () => { + beforeEach(() => { + const newPages = [ + { + path: `/about/`, + componentChunkName: `page-component---src-pages-test-js`, + jsonName: `about.json`, + }, + { + path: `/about/me/`, + componentChunkName: `page-component---src-pages-test-js`, + jsonName: `about-me.json`, + }, + { + path: `/about/the best/`, + componentChunkName: `page-component---src-pages-test-js`, + jsonName: `the-best.json`, + }, + { + path: `/app/`, + matchPath: `/app/*`, + componentChunkName: `page-component---src-pages-app-js`, + jsonName: `app.json`, + }, + ] + findPage = pageFinderFactory(newPages) + }) + + it(`can find a page`, () => { + expect(findPage(`/about/`).path).toBe(`/about/`) + expect(findPage(`/about/me/`).path).toBe(`/about/me/`) + }) + + it(`can find a page with space in its path`, () => { + expect(findPage(`/about/the best/`).path).toBe(`/about/the best/`) + expect(findPage(`/about/the%20best/`).path).toBe(`/about/the best/`) + }) + + it(`can find a client only path`, () => { + expect(findPage(`/about/super-duper/`)).toBeUndefined() + expect(findPage(`/app/client/only/path`).path).toBe(`/app/`) + }) + + it(`can find links with hashes`, () => { + expect(findPage(`/about/me/#hashtagawesome`).path).toBe(`/about/me/`) + }) + + it(`can find links with search query`, () => { + expect(findPage(`/about/me/?query=awesome`).path).toBe(`/about/me/`) + }) + + it(`handles finding prefixed links`, () => { + const newPages = [ + { + path: `/about/`, + componentChunkName: `page-component---src-pages-test-js`, + jsonName: `about.json`, + }, + ] + const findPage2 = pageFinderFactory(newPages, `/my-test-prefix`) + expect(findPage2(`/my-test-prefix/about/`).path).toBe(`/about/`) + }) +}) diff --git a/packages/gatsby-theme/.cache/__tests__/minimal-config.js b/packages/gatsby-theme/.cache/__tests__/minimal-config.js new file mode 100644 index 0000000..ef2c4c9 --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/minimal-config.js @@ -0,0 +1,32 @@ +const path = require(`path`) +const child = require(`child_process`) + +it(`Builds cache-dir with minimal config`, done => { + const args = [ + require.resolve(`@babel/cli/bin/babel.js`), + path.join(__dirname, `..`), + `--config-file`, + path.join(__dirname, `.babelrc`), + `--ignore`, + `**/__tests__`, + ] + + const spawn = child.spawn(process.execPath, args) + + let stderr = `` + let stdout = `` + + spawn.stderr.on(`data`, function(chunk) { + stderr += chunk + }) + + spawn.stdout.on(`data`, function(chunk) { + stdout += chunk + }) + + spawn.on(`close`, function() { + expect(stderr).toEqual(``) + expect(stdout).not.toEqual(``) + done() + }) +}, 30000) diff --git a/packages/gatsby-theme/.cache/__tests__/static-entry.js b/packages/gatsby-theme/.cache/__tests__/static-entry.js new file mode 100644 index 0000000..1dbf93f --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/static-entry.js @@ -0,0 +1,274 @@ +import React from 'react' +import fs from 'fs' + +import DevelopStaticEntry from '../develop-static-entry' + +jest.mock(`fs`, () => { + const fs = jest.requireActual(`fs`) + return { + ...fs, + readFileSync: jest.fn(), + } +}) +jest.mock(`gatsby/package.json`, () => { + return { + version: `2.0.0`, + } +}) + +jest.mock( + `../sync-requires`, + () => { + return { + components: { + 'page-component---src-pages-test-js': () => null, + }, + } + }, + { + virtual: true, + } +) + +jest.mock( + `../data.json`, + () => { + return { + dataPaths: [ + { + [`about.json`]: `/400/about`, + }, + ], + pages: [ + { + path: `/about/`, + componentChunkName: `page-component---src-pages-test-js`, + jsonName: `about.json`, + }, + ], + } + }, + { + virtual: true, + } +) + +const MOCK_FILE_INFO = { + [`${process.cwd()}/public/webpack.stats.json`]: `{}`, + [`${process.cwd()}/public/chunk-map.json`]: `{}`, +} + +let StaticEntry +beforeEach(() => { + fs.readFileSync.mockImplementation(file => MOCK_FILE_INFO[file]) + StaticEntry = require(`../static-entry`).default +}) + +const reverseHeadersPlugin = { + plugin: { + onPreRenderHTML: ({ getHeadComponents, replaceHeadComponents }) => { + const headComponents = getHeadComponents() + headComponents.reverse() + replaceHeadComponents(headComponents) + }, + }, +} + +const injectValuePlugin = (hookName, methodName, value) => { + return { + plugin: { + [hookName]: staticEntry => { + const method = staticEntry[methodName] + method(value) + }, + }, + } +} + +const checkSanitized = components => { + expect(components.includes(null)).toBeFalsy() + expect( + components.find(val => Array.isArray(val) && val.length === 0) + ).toBeFalsy() +} + +const checkNonEmptyHeadersPlugin = { + plugin: { + onPreRenderHTML: ({ + getHeadComponents, + getPreBodyComponents, + getPostBodyComponents, + }) => { + const headComponents = getHeadComponents() + const preBodyComponents = getPreBodyComponents() + const postBodyComponents = getPostBodyComponents() + checkSanitized(headComponents) + checkSanitized(preBodyComponents) + checkSanitized(postBodyComponents) + }, + }, +} + +const fakeStylesPlugin = { + plugin: { + onRenderBody: ({ setHeadComponents }) => + setHeadComponents([ + , + , + , + ]), + }, +} + +const reverseBodyComponentsPluginFactory = type => { + return { + plugin: { + onPreRenderHTML: props => { + const components = props[`get${type}BodyComponents`]() + components.reverse() + props[`replace${type}BodyComponents`](components) + }, + }, + } +} + +const fakeComponentsPluginFactory = type => { + return { + plugin: { + onRenderBody: props => { + props[`set${type}BodyComponents`]([ +
div1
, +
div2
, +
div3
, + ]) + }, + }, + } +} + +describe(`develop-static-entry`, () => { + test(`onPreRenderHTML can be used to replace headComponents`, done => { + global.plugins = [fakeStylesPlugin, reverseHeadersPlugin] + + DevelopStaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) + + test(`onPreRenderHTML can be used to replace postBodyComponents`, done => { + global.plugins = [ + fakeComponentsPluginFactory(`Post`), + reverseBodyComponentsPluginFactory(`Post`), + ] + + DevelopStaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) + + test(`onPreRenderHTML can be used to replace preBodyComponents`, done => { + global.plugins = [ + fakeComponentsPluginFactory(`Pre`), + reverseBodyComponentsPluginFactory(`Pre`), + ] + + DevelopStaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) +}) + +describe(`static-entry sanity checks`, () => { + beforeEach(() => { + global.__PATH_PREFIX__ = `` + }) + + const methodsToCheck = [ + `replaceHeadComponents`, + `replacePreBodyComponents`, + `replacePostBodyComponents`, + ] + + methodsToCheck.forEach(methodName => { + test(`${methodName} can filter out null value`, done => { + const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, null) + global.plugins = [plugin, checkNonEmptyHeadersPlugin] + + StaticEntry(`/about/`, (_, html) => { + done() + }) + }) + + test(`${methodName} can filter out null values`, done => { + const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, [ + null, + null, + ]) + global.plugins = [plugin, checkNonEmptyHeadersPlugin] + + StaticEntry(`/about/`, (_, html) => { + done() + }) + }) + + test(`${methodName} can filter out empty array`, done => { + const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, []) + global.plugins = [plugin, checkNonEmptyHeadersPlugin] + + StaticEntry(`/about/`, (_, html) => { + done() + }) + }) + + test(`${methodName} can filter out empty arrays`, done => { + const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, [[], []]) + global.plugins = [plugin, checkNonEmptyHeadersPlugin] + + StaticEntry(`/about/`, (_, html) => { + done() + }) + }) + }) +}) + +describe(`static-entry`, () => { + beforeEach(() => { + global.__PATH_PREFIX__ = `` + }) + + test(`onPreRenderHTML can be used to replace headComponents`, done => { + global.plugins = [fakeStylesPlugin, reverseHeadersPlugin] + + StaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) + + test(`onPreRenderHTML can be used to replace postBodyComponents`, done => { + global.plugins = [ + fakeComponentsPluginFactory(`Post`), + reverseBodyComponentsPluginFactory(`Post`), + ] + + StaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) + + test(`onPreRenderHTML can be used to replace preBodyComponents`, done => { + global.plugins = [ + fakeComponentsPluginFactory(`Pre`), + reverseBodyComponentsPluginFactory(`Pre`), + ] + + StaticEntry(`/about/`, (_, html) => { + expect(html).toMatchSnapshot() + done() + }) + }) +}) diff --git a/packages/gatsby-theme/.cache/__tests__/strip-prefix.js b/packages/gatsby-theme/.cache/__tests__/strip-prefix.js new file mode 100644 index 0000000..78fc19b --- /dev/null +++ b/packages/gatsby-theme/.cache/__tests__/strip-prefix.js @@ -0,0 +1,23 @@ +const stripPrefix = require(`../strip-prefix`).default + +describe(`strip-prefix`, () => { + it(`strips a prefix`, () => { + expect(stripPrefix(`/foo/bar/`, `/foo`)).toBe(`/bar/`) + }) + + it(`strips first instance only`, () => { + expect(stripPrefix(`/foo/foo/bar/`, `/foo`)).toBe(`/foo/bar/`) + }) + + it(`ignores prefix appearing elsewhere in the string`, () => { + expect(stripPrefix(`/foo/bar/`, `bar`)).toBe(`/foo/bar/`) + }) + + it(`ignores a non-existent prefix`, () => { + expect(stripPrefix(`/bar`, `/foo`)).toBe(`/bar`) + }) + + it(`returns input str if no prefix is provided`, () => { + expect(stripPrefix(`/bar`)).toBe(`/bar`) + }) +}) diff --git a/packages/gatsby-theme/.cache/api-runner-browser-plugins.js b/packages/gatsby-theme/.cache/api-runner-browser-plugins.js new file mode 100644 index 0000000..19a4308 --- /dev/null +++ b/packages/gatsby-theme/.cache/api-runner-browser-plugins.js @@ -0,0 +1,6 @@ +module.exports = [ + { + plugin: require('/Users/jxnblk/repos/mdx-deck/node_modules/gatsby-mdx/gatsby-browser.js'), + options: { plugins: [], extensions: ['.mdx', '.md'] }, + }, +] diff --git a/packages/gatsby-theme/.cache/api-runner-browser.js b/packages/gatsby-theme/.cache/api-runner-browser.js new file mode 100644 index 0000000..0a4ff8b --- /dev/null +++ b/packages/gatsby-theme/.cache/api-runner-browser.js @@ -0,0 +1,55 @@ +const plugins = require(`./api-runner-browser-plugins`) +const { + getResourcesForPathname, + getResourcesForPathnameSync, + getResourceURLsForPathname, +} = require(`./loader`).publicLoader + +exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => { + // Hooks for gatsby-cypress's API handler + if (process.env.CYPRESS_SUPPORT) { + if (window.___apiHandler) { + window.___apiHandler(api) + } else if (window.___resolvedAPIs) { + window.___resolvedAPIs.push(api) + } else { + window.___resolvedAPIs = [api] + } + } + + let results = plugins.map(plugin => { + if (!plugin.plugin[api]) { + return undefined + } + + args.getResourcesForPathnameSync = getResourcesForPathnameSync + args.getResourcesForPathname = getResourcesForPathname + args.getResourceURLsForPathname = getResourceURLsForPathname + + const result = plugin.plugin[api](args, plugin.options) + if (result && argTransform) { + args = argTransform({ args, result, plugin }) + } + return result + }) + + // Filter out undefined results. + results = results.filter(result => typeof result !== `undefined`) + + if (results.length > 0) { + return results + } else if (defaultReturn) { + return [defaultReturn] + } else { + return [] + } +} + +exports.apiRunnerAsync = (api, args, defaultReturn) => + plugins.reduce( + (previous, next) => + next.plugin[api] + ? previous.then(() => next.plugin[api](args, next.options)) + : previous, + Promise.resolve() + ) diff --git a/packages/gatsby-theme/.cache/api-runner-ssr.js b/packages/gatsby-theme/.cache/api-runner-ssr.js new file mode 100644 index 0000000..cfbcbf1 --- /dev/null +++ b/packages/gatsby-theme/.cache/api-runner-ssr.js @@ -0,0 +1,48 @@ +var plugins = [ + { + plugin: require('/Users/jxnblk/repos/mdx-deck/node_modules/gatsby-mdx/gatsby-ssr'), + options: { plugins: [], extensions: ['.mdx', '.md'] }, + }, +] +// During bootstrap, we write requires at top of this file which looks like: +// var plugins = [ +// { +// plugin: require("/path/to/plugin1/gatsby-ssr.js"), +// options: { ... }, +// }, +// { +// plugin: require("/path/to/plugin2/gatsby-ssr.js"), +// options: { ... }, +// }, +// ] + +const apis = require(`./api-ssr-docs`) + +// Run the specified API in any plugins that have implemented it +module.exports = (api, args, defaultReturn, argTransform) => { + if (!apis[api]) { + console.log(`This API doesn't exist`, api) + } + + // Run each plugin in series. + // eslint-disable-next-line no-undef + let results = plugins.map(plugin => { + if (!plugin.plugin[api]) { + return undefined + } + const result = plugin.plugin[api](args, plugin.options) + if (result && argTransform) { + args = argTransform({ args, result }) + } + return result + }) + + // Filter out undefined results. + results = results.filter(result => typeof result !== `undefined`) + + if (results.length > 0) { + return results + } else { + return [defaultReturn] + } +} diff --git a/packages/gatsby-theme/.cache/api-ssr-docs.js b/packages/gatsby-theme/.cache/api-ssr-docs.js new file mode 100644 index 0000000..b2897dd --- /dev/null +++ b/packages/gatsby-theme/.cache/api-ssr-docs.js @@ -0,0 +1,181 @@ +/** + * Replace the default server renderer. This is useful for integration with + * Redux, css-in-js libraries, etc. that need custom setups for server + * rendering. + * @param {Object} $0 + * @param {function} $0.replaceBodyHTMLString Call this with the HTML string + * you render. **WARNING** if multiple plugins implement this API it's the + * last plugin that "wins". TODO implement an automated warning against this. + * @param {function} $0.setHeadComponents Takes an array of components as its + * first argument which are added to the `headComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setHtmlAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setBodyAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setPreBodyComponents Takes an array of components as its + * first argument which are added to the `preBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setPostBodyComponents Takes an array of components as its + * first argument which are added to the `postBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setBodyProps Takes an object of data which + * is merged with other body props and passed to `html.js` as `bodyProps`. + * @param {Object} pluginOptions + * @example + * // From gatsby-plugin-glamor + * const { renderToString } = require("react-dom/server") + * const inline = require("glamor-inline") + * + * exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { + * const bodyHTML = renderToString(bodyComponent) + * const inlinedHTML = inline(bodyHTML) + * + * replaceBodyHTMLString(inlinedHTML) + * } + */ +exports.replaceRenderer = true + +/** + * Called after every page Gatsby server renders while building HTML so you can + * set head and body components to be rendered in your `html.js`. + * + * Gatsby does a two-pass render for HTML. It loops through your pages first + * rendering only the body and then takes the result body HTML string and + * passes it as the `body` prop to your `html.js` to complete the render. + * + * It's often handy to be able to send custom components to your `html.js`. + * For example, it's a very common pattern for React.js libraries that + * support server rendering to pull out data generated during the render to + * add to your HTML. + * + * Using this API over [`replaceRenderer`](#replaceRenderer) is preferable as + * multiple plugins can implement this API where only one plugin can take + * over server rendering. However, if your plugin requires taking over server + * rendering then that's the one to + * use + * @param {Object} $0 + * @param {string} $0.pathname The pathname of the page currently being rendered. + * @param {function} $0.setHeadComponents Takes an array of components as its + * first argument which are added to the `headComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setHtmlAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setBodyAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setPreBodyComponents Takes an array of components as its + * first argument which are added to the `preBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setPostBodyComponents Takes an array of components as its + * first argument which are added to the `postBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setBodyProps Takes an object of data which + * is merged with other body props and passed to `html.js` as `bodyProps`. + * @param {Object} pluginOptions + * @example + * const { Helmet } = require("react-helmet") + * + * exports.onRenderBody = ( + * { setHeadComponents, setHtmlAttributes, setBodyAttributes }, + * pluginOptions + * ) => { + * const helmet = Helmet.renderStatic() + * setHtmlAttributes(helmet.htmlAttributes.toComponent()) + * setBodyAttributes(helmet.bodyAttributes.toComponent()) + * setHeadComponents([ + * helmet.title.toComponent(), + * helmet.link.toComponent(), + * helmet.meta.toComponent(), + * helmet.noscript.toComponent(), + * helmet.script.toComponent(), + * helmet.style.toComponent(), + * ]) + * } + */ +exports.onRenderBody = true + +/** + * Called after every page Gatsby server renders while building HTML so you can + * replace head components to be rendered in your `html.js`. This is useful if + * you need to reorder scripts or styles added by other plugins. + * @param {Object} $0 + * @param {Array} $0.getHeadComponents Returns the current `headComponents` array. + * @param {function} $0.replaceHeadComponents Takes an array of components as its + * first argument which replace the `headComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Array} $0.getPreBodyComponents Returns the current `preBodyComponents` array. + * @param {function} $0.replacePreBodyComponents Takes an array of components as its + * first argument which replace the `preBodyComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Array} $0.getPostBodyComponents Returns the current `postBodyComponents` array. + * @param {function} $0.replacePostBodyComponents Takes an array of components as its + * first argument which replace the `postBodyComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Object} pluginOptions + * @example + * // Move Typography.js styles to the top of the head section so they're loaded first. + * exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => { + * const headComponents = getHeadComponents() + * headComponents.sort((x, y) => { + * if (x.key === 'TypographyStyle') { + * return -1 + * } else if (y.key === 'TypographyStyle') { + * return 1 + * } + * return 0 + * }) + * replaceHeadComponents(headComponents) + * } + */ +exports.onPreRenderHTML = true + +/** + * Allow a plugin to wrap the page element. + * + * This is useful for setting wrapper component around pages that won't get + * unmounted on page change. For setting Provider components use [wrapRootElement](#wrapRootElement). + * + * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapPageElement) + * @param {object} $0 + * @param {ReactNode} $0.element The "Page" React Element built by Gatsby. + * @param {object} $0.props Props object used by page. + * @example + * import React from "react" + * import Layout from "./src/components/layout" + * + * export const wrapPageElement = ({ element, props }) => { + * // props provide same data to Layout as Page element will get + * // including location, data, etc - you don't need to pass it + * return {element} + * } + */ +exports.wrapPageElement = true + +/** + * Allow a plugin to wrap the root element. + * + * This is useful to setup any Providers component that will wrap your application. + * For setting persistent UI elements around pages use [wrapPageElement](#wrapPageElement). + * + * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapRootElement) + * @param {object} $0 + * @param {ReactNode} $0.element The "Root" React Element built by Gatsby. + * @example + * import React from "react" + * import { Provider } from "react-redux" + * + * import createStore from "./src/state/createStore" + * const store = createStore() + * + * export const wrapRootElement = ({ element }) => { + * return ( + * + * {element} + * + * ) + * } + */ +exports.wrapRootElement = true diff --git a/packages/gatsby-theme/.cache/app.js b/packages/gatsby-theme/.cache/app.js new file mode 100644 index 0000000..d161b75 --- /dev/null +++ b/packages/gatsby-theme/.cache/app.js @@ -0,0 +1,69 @@ +import React from 'react' +import ReactDOM from 'react-dom' +import domReady from '@mikaelkristiansson/domready' + +import socketIo from './socketIo' +import emitter from './emitter' +import { apiRunner, apiRunnerAsync } from './api-runner-browser' +import loader, { setApiRunnerForLoader, postInitialRenderWork } from './loader' +import syncRequires from './sync-requires' +import pages from './pages.json' + +window.___emitter = emitter +setApiRunnerForLoader(apiRunner) + +// Let the site/plugins run code very early. +apiRunnerAsync(`onClientEntry`).then(() => { + // Hook up the client to socket.io on server + const socket = socketIo() + if (socket) { + socket.on(`reload`, () => { + window.location.reload() + }) + } + + /** + * Service Workers are persistent by nature. They stick around, + * serving a cached version of the site if they aren't removed. + * This is especially frustrating when you need to test the + * production build on your local machine. + * + * Let's unregister the service workers in development, and tidy up a few errors. + */ + if (supportsServiceWorkers(location, navigator)) { + navigator.serviceWorker.getRegistrations().then(registrations => { + for (let registration of registrations) { + registration.unregister() + } + }) + } + + const rootElement = document.getElementById(`___gatsby`) + + const renderer = apiRunner( + `replaceHydrateFunction`, + undefined, + ReactDOM.render + )[0] + + loader.addPagesArray(pages) + loader.addDevRequires(syncRequires) + + loader.getResourcesForPathname(window.location.pathname).then(() => { + const preferDefault = m => (m && m.default) || m + let Root = preferDefault(require(`./root`)) + domReady(() => { + renderer(, rootElement, () => { + postInitialRenderWork() + apiRunner(`onInitialClientRender`) + }) + }) + }) +}) + +function supportsServiceWorkers(location, navigator) { + if (location.hostname === `localhost` || location.protocol === `https:`) { + return `serviceWorker` in navigator + } + return false +} diff --git a/packages/gatsby-theme/.cache/async-requires.js b/packages/gatsby-theme/.cache/async-requires.js new file mode 100644 index 0000000..2786308 --- /dev/null +++ b/packages/gatsby-theme/.cache/async-requires.js @@ -0,0 +1,16 @@ +// prefer default export if available +const preferDefault = m => (m && m.default) || m + +exports.components = { + 'component---src-decks-js': () => + import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/decks.js' /* webpackChunkName: "component---src-decks-js" */), + 'component---src-template-js': () => + import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/template.js' /* webpackChunkName: "component---src-template-js" */), + 'component---cache-dev-404-page-js': () => + import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/.cache/dev-404-page.js' /* webpackChunkName: "component---cache-dev-404-page-js" */), + 'component---src-pages-index-mdx': () => + import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/pages/index.mdx' /* webpackChunkName: "component---src-pages-index-mdx" */), +} + +exports.data = () => + import(/* webpackChunkName: "pages-manifest" */ '/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/.cache/data.json') diff --git a/packages/gatsby-theme/.cache/babelState.json b/packages/gatsby-theme/.cache/babelState.json new file mode 100644 index 0000000..8c8cbaf --- /dev/null +++ b/packages/gatsby-theme/.cache/babelState.json @@ -0,0 +1,57 @@ +{ + "stages": { + "develop": { + "plugins": [ + { + "name": "@babel/plugin-proposal-object-rest-spread", + "options": {} + } + ], + "presets": [], + "options": { + "cacheDirectory": true, + "sourceType": "unambiguous" + } + }, + "develop-html": { + "plugins": [ + { + "name": "@babel/plugin-proposal-object-rest-spread", + "options": {} + } + ], + "presets": [], + "options": { + "cacheDirectory": true, + "sourceType": "unambiguous" + } + }, + "build-html": { + "plugins": [ + { + "name": "@babel/plugin-proposal-object-rest-spread", + "options": {} + } + ], + "presets": [], + "options": { + "cacheDirectory": true, + "sourceType": "unambiguous" + } + }, + "build-javascript": { + "plugins": [ + { + "name": "@babel/plugin-proposal-object-rest-spread", + "options": {} + } + ], + "presets": [], + "options": { + "cacheDirectory": true, + "sourceType": "unambiguous" + } + } + }, + "browserslist": [">0.25%", "not dead"] +} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json new file mode 100644 index 0000000..a8d5f08 --- /dev/null +++ b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json @@ -0,0 +1,84 @@ +{ + "expireTime": 9007200809682330000, + "key": "gatsby-mdx-entire-payload-baeb8a140a332d9bf75f44c55c64cb65-", + "val": { + "mdast": { + "type": "root", + "children": [ + { + "type": "import", + "value": "import { Link } from 'gatsby'", + "position": { + "start": { "line": 1, "column": 1, "offset": 0 }, + "end": { "line": 1, "column": 30, "offset": 29 }, + "indent": [] + } + }, + { + "type": "heading", + "depth": 1, + "children": [ + { + "type": "text", + "value": "@mdx-deck/gatsby-theme", + "position": { + "start": { "line": 3, "column": 3, "offset": 33 }, + "end": { "line": 3, "column": 25, "offset": 55 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 3, "column": 1, "offset": 31 }, + "end": { "line": 3, "column": 25, "offset": 55 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "A Gatsby theme for creating presentation decks with MDX", + "position": { + "start": { "line": 5, "column": 1, "offset": 57 }, + "end": { "line": 5, "column": 56, "offset": 112 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 5, "column": 1, "offset": 57 }, + "end": { "line": 5, "column": 56, "offset": 112 }, + "indent": [] + } + }, + { + "type": "jsx", + "value": "View decks", + "position": { + "start": { "line": 7, "column": 1, "offset": 114 }, + "end": { "line": 7, "column": 36, "offset": 149 }, + "indent": [] + } + }, + { + "type": "export", + "value": "export const _frontmatter = {}", + "position": { + "start": { "line": 11, "column": 1, "offset": 153 }, + "end": { "line": 11, "column": 31, "offset": 183 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 1, "column": 1, "offset": 0 }, + "end": { "line": 11, "column": 31, "offset": 183 } + } + }, + "scopeImports": [], + "scopeIdentifiers": [], + "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\nimport { Link } from 'gatsby'\nexport const _frontmatter = {}\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n\n

{`@mdx-deck/gatsby-theme`}

\n

{`A Gatsby theme for creating presentation decks with MDX`}

\nView decks\n\n \n )\n}\nMDXContent.isMDXComponent = true" + } +} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json new file mode 100644 index 0000000..e2ee3b7 --- /dev/null +++ b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json @@ -0,0 +1,258 @@ +{ + "expireTime": 9007200809682327000, + "key": "gatsby-mdx-entire-payload-5769e800aec14b9252f179abd94cf8d5-", + "val": { + "mdast": { + "type": "root", + "children": [ + { + "type": "export", + "value": "export const theme = {\n colors: {\n text: 'tomato',\n background: 'black',\n }\n}", + "position": { + "start": { "line": 2, "column": 1, "offset": 1 }, + "end": { "line": 7, "column": 2, "offset": 86 }, + "indent": [1, 1, 1, 1, 1] + } + }, + { + "type": "heading", + "depth": 1, + "children": [ + { + "type": "text", + "value": "Hello", + "position": { + "start": { "line": 9, "column": 3, "offset": 90 }, + "end": { "line": 9, "column": 8, "offset": 95 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 9, "column": 1, "offset": 88 }, + "end": { "line": 9, "column": 8, "offset": 95 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 11, "column": 1, "offset": 97 }, + "end": { "line": 11, "column": 4, "offset": 100 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "This is the MDX Deck Gatsby theme", + "position": { + "start": { "line": 13, "column": 1, "offset": 102 }, + "end": { "line": 13, "column": 34, "offset": 135 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 13, "column": 1, "offset": 102 }, + "end": { "line": 13, "column": 34, "offset": 135 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 15, "column": 1, "offset": 137 }, + "end": { "line": 15, "column": 4, "offset": 140 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "inlineCode", + "value": "npm i @mdx-deck/gatsby-theme", + "position": { + "start": { "line": 17, "column": 1, "offset": 142 }, + "end": { "line": 17, "column": 31, "offset": 172 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 17, "column": 1, "offset": 142 }, + "end": { "line": 17, "column": 31, "offset": 172 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 19, "column": 1, "offset": 174 }, + "end": { "line": 19, "column": 4, "offset": 177 }, + "indent": [] + } + }, + { + "type": "code", + "lang": "js", + "meta": null, + "value": "// gatsby-config.js\nmodule.exports = {\n __experimentalThemes: [\n '@mdx-deck/gatsby-theme',\n ]\n}", + "position": { + "start": { "line": 21, "column": 1, "offset": 179 }, + "end": { "line": 28, "column": 4, "offset": 289 }, + "indent": [1, 1, 1, 1, 1, 1, 1] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 30, "column": 1, "offset": 291 }, + "end": { "line": 30, "column": 4, "offset": 294 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "inlineCode", + "value": "mkdir src src/decks", + "position": { + "start": { "line": 32, "column": 1, "offset": 296 }, + "end": { "line": 32, "column": 22, "offset": 317 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 32, "column": 1, "offset": 296 }, + "end": { "line": 32, "column": 22, "offset": 317 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 34, "column": 1, "offset": 319 }, + "end": { "line": 34, "column": 4, "offset": 322 }, + "indent": [] + } + }, + { + "type": "list", + "ordered": true, + "start": 1, + "spread": false, + "children": [ + { + "type": "listItem", + "spread": false, + "checked": null, + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "Add an MDX deck to ", + "position": { + "start": { "line": 36, "column": 4, "offset": 327 }, + "end": { "line": 36, "column": 23, "offset": 346 }, + "indent": [] + } + }, + { + "type": "inlineCode", + "value": "src/decks", + "position": { + "start": { "line": 36, "column": 23, "offset": 346 }, + "end": { "line": 36, "column": 34, "offset": 357 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 36, "column": 4, "offset": 327 }, + "end": { "line": 36, "column": 34, "offset": 357 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 36, "column": 1, "offset": 324 }, + "end": { "line": 36, "column": 34, "offset": 357 }, + "indent": [] + } + }, + { + "type": "listItem", + "spread": false, + "checked": null, + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "Navigate to ", + "position": { + "start": { "line": 37, "column": 4, "offset": 361 }, + "end": { "line": 37, "column": 16, "offset": 373 }, + "indent": [] + } + }, + { + "type": "inlineCode", + "value": "http://localhost.com/decks", + "position": { + "start": { "line": 37, "column": 16, "offset": 373 }, + "end": { "line": 37, "column": 44, "offset": 401 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 37, "column": 4, "offset": 361 }, + "end": { "line": 37, "column": 44, "offset": 401 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 37, "column": 1, "offset": 358 }, + "end": { "line": 37, "column": 44, "offset": 401 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 36, "column": 1, "offset": 324 }, + "end": { "line": 37, "column": 44, "offset": 401 }, + "indent": [1] + } + }, + { + "type": "export", + "value": "export const _frontmatter = {}", + "position": { + "start": { "line": 41, "column": 1, "offset": 405 }, + "end": { "line": 41, "column": 31, "offset": 435 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 1, "column": 1, "offset": 0 }, + "end": { "line": 41, "column": 31, "offset": 435 } + } + }, + "scopeImports": ["import React from 'react'"], + "scopeIdentifiers": ["React"], + "body": "function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar theme = {\n colors: {\n text: 'tomato',\n background: 'black'\n }\n};\nvar _frontmatter = {};\nvar layoutProps = {\n theme: theme,\n _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n var components = _ref.components,\n props = _objectWithoutProperties(_ref, [\"components\"]);\n\n return mdx(MDXLayout, _extends({}, layoutProps, props, {\n components: components\n }), mdx(\"h1\", null, \"Hello\"), mdx(\"hr\", null), mdx(\"p\", null, \"This is the MDX Deck Gatsby theme\"), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"npm i @mdx-deck/gatsby-theme\")), mdx(\"hr\", null), mdx(\"pre\", null, mdx(\"code\", _extends({\n parentName: \"pre\"\n }, {\n \"className\": \"language-js\"\n }), \"// gatsby-config.js\\nmodule.exports = {\\n __experimentalThemes: [\\n '@mdx-deck/gatsby-theme',\\n ]\\n}\\n\")), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"mkdir src src/decks\")), mdx(\"hr\", null), mdx(\"ol\", null, mdx(\"li\", {\n parentName: \"ol\"\n }, \"Add an MDX deck to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"src/decks\")), mdx(\"li\", {\n parentName: \"ol\"\n }, \"Navigate to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"http://localhost.com/decks\"))));\n}\nMDXContent.isMDXComponent = true;", + "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\n\nexport const theme = {\n colors: {\n text: 'tomato',\n background: 'black',\n }\n}\nexport const _frontmatter = {}\nconst layoutProps = {\n theme,\n_frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n\n

{`Hello`}

\n
\n

{`This is the MDX Deck Gatsby theme`}

\n
\n

{`npm i @mdx-deck/gatsby-theme`}

\n
\n
{`// gatsby-config.js\nmodule.exports = {\n  __experimentalThemes: [\n    '@mdx-deck/gatsby-theme',\n  ]\n}\n`}
\n
\n

{`mkdir src src/decks`}

\n
\n
    \n
  1. {`Add an MDX deck to `}{`src/decks`}
  2. \n
  3. {`Navigate to `}{`http://localhost.com/decks`}
  4. \n
\n\n \n )\n}\nMDXContent.isMDXComponent = true" + } +} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json new file mode 100644 index 0000000..9bf352f --- /dev/null +++ b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json @@ -0,0 +1,249 @@ +{ + "expireTime": 9007200809682853000, + "key": "gatsby-mdx-entire-payload-fb7375c64a5b69bbc2f3ed91d99452df-", + "val": { + "mdast": { + "type": "root", + "children": [ + { + "type": "heading", + "depth": 1, + "children": [ + { + "type": "text", + "value": "Hello", + "position": { + "start": { "line": 2, "column": 3, "offset": 3 }, + "end": { "line": 2, "column": 8, "offset": 8 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 2, "column": 1, "offset": 1 }, + "end": { "line": 2, "column": 8, "offset": 8 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 4, "column": 1, "offset": 10 }, + "end": { "line": 4, "column": 4, "offset": 13 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "This is the MDX Deck Gatsby theme", + "position": { + "start": { "line": 6, "column": 1, "offset": 15 }, + "end": { "line": 6, "column": 34, "offset": 48 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 6, "column": 1, "offset": 15 }, + "end": { "line": 6, "column": 34, "offset": 48 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 8, "column": 1, "offset": 50 }, + "end": { "line": 8, "column": 4, "offset": 53 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "inlineCode", + "value": "npm i @mdx-deck/gatsby-theme", + "position": { + "start": { "line": 10, "column": 1, "offset": 55 }, + "end": { "line": 10, "column": 31, "offset": 85 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 10, "column": 1, "offset": 55 }, + "end": { "line": 10, "column": 31, "offset": 85 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 12, "column": 1, "offset": 87 }, + "end": { "line": 12, "column": 4, "offset": 90 }, + "indent": [] + } + }, + { + "type": "code", + "lang": "js", + "meta": null, + "value": "// gatsby-config.js\nmodule.exports = {\n __experimentalThemes: [\n '@mdx-deck/gatsby-theme',\n ]\n}", + "position": { + "start": { "line": 14, "column": 1, "offset": 92 }, + "end": { "line": 21, "column": 4, "offset": 202 }, + "indent": [1, 1, 1, 1, 1, 1, 1] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 23, "column": 1, "offset": 204 }, + "end": { "line": 23, "column": 4, "offset": 207 }, + "indent": [] + } + }, + { + "type": "paragraph", + "children": [ + { + "type": "inlineCode", + "value": "mkdir src src/decks", + "position": { + "start": { "line": 25, "column": 1, "offset": 209 }, + "end": { "line": 25, "column": 22, "offset": 230 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 25, "column": 1, "offset": 209 }, + "end": { "line": 25, "column": 22, "offset": 230 }, + "indent": [] + } + }, + { + "type": "thematicBreak", + "position": { + "start": { "line": 27, "column": 1, "offset": 232 }, + "end": { "line": 27, "column": 4, "offset": 235 }, + "indent": [] + } + }, + { + "type": "list", + "ordered": true, + "start": 1, + "spread": false, + "children": [ + { + "type": "listItem", + "spread": false, + "checked": null, + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "Add an MDX deck to ", + "position": { + "start": { "line": 29, "column": 4, "offset": 240 }, + "end": { "line": 29, "column": 23, "offset": 259 }, + "indent": [] + } + }, + { + "type": "inlineCode", + "value": "src/decks", + "position": { + "start": { "line": 29, "column": 23, "offset": 259 }, + "end": { "line": 29, "column": 34, "offset": 270 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 29, "column": 4, "offset": 240 }, + "end": { "line": 29, "column": 34, "offset": 270 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 29, "column": 1, "offset": 237 }, + "end": { "line": 29, "column": 34, "offset": 270 }, + "indent": [] + } + }, + { + "type": "listItem", + "spread": false, + "checked": null, + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "text", + "value": "Navigate to ", + "position": { + "start": { "line": 30, "column": 4, "offset": 274 }, + "end": { "line": 30, "column": 16, "offset": 286 }, + "indent": [] + } + }, + { + "type": "inlineCode", + "value": "http://localhost.com/decks", + "position": { + "start": { "line": 30, "column": 16, "offset": 286 }, + "end": { "line": 30, "column": 44, "offset": 314 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 30, "column": 4, "offset": 274 }, + "end": { "line": 30, "column": 44, "offset": 314 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 30, "column": 1, "offset": 271 }, + "end": { "line": 30, "column": 44, "offset": 314 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 29, "column": 1, "offset": 237 }, + "end": { "line": 30, "column": 44, "offset": 314 }, + "indent": [1] + } + }, + { + "type": "export", + "value": "export const _frontmatter = {}", + "position": { + "start": { "line": 34, "column": 1, "offset": 318 }, + "end": { "line": 34, "column": 31, "offset": 348 }, + "indent": [] + } + } + ], + "position": { + "start": { "line": 1, "column": 1, "offset": 0 }, + "end": { "line": 34, "column": 31, "offset": 348 } + } + }, + "scopeImports": ["import React from 'react'"], + "scopeIdentifiers": ["React"], + "body": "function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {};\nvar layoutProps = {\n _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n var components = _ref.components,\n props = _objectWithoutProperties(_ref, [\"components\"]);\n\n return mdx(MDXLayout, _extends({}, layoutProps, props, {\n components: components\n }), mdx(\"h1\", null, \"Hello\"), mdx(\"hr\", null), mdx(\"p\", null, \"This is the MDX Deck Gatsby theme\"), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"npm i @mdx-deck/gatsby-theme\")), mdx(\"hr\", null), mdx(\"pre\", null, mdx(\"code\", _extends({\n parentName: \"pre\"\n }, {\n \"className\": \"language-js\"\n }), \"// gatsby-config.js\\nmodule.exports = {\\n __experimentalThemes: [\\n '@mdx-deck/gatsby-theme',\\n ]\\n}\\n\")), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"mkdir src src/decks\")), mdx(\"hr\", null), mdx(\"ol\", null, mdx(\"li\", {\n parentName: \"ol\"\n }, \"Add an MDX deck to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"src/decks\")), mdx(\"li\", {\n parentName: \"ol\"\n }, \"Navigate to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"http://localhost.com/decks\"))));\n}\nMDXContent.isMDXComponent = true;", + "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\n\nexport const _frontmatter = {}\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n

{`Hello`}

\n
\n

{`This is the MDX Deck Gatsby theme`}

\n
\n

{`npm i @mdx-deck/gatsby-theme`}

\n
\n
{`// gatsby-config.js\nmodule.exports = {\n  __experimentalThemes: [\n    '@mdx-deck/gatsby-theme',\n  ]\n}\n`}
\n
\n

{`mkdir src src/decks`}

\n
\n
    \n
  1. {`Add an MDX deck to `}{`src/decks`}
  2. \n
  3. {`Navigate to `}{`http://localhost.com/decks`}
  4. \n
\n\n \n )\n}\nMDXContent.isMDXComponent = true" + } +} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js b/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js new file mode 100644 index 0000000..fa770bb --- /dev/null +++ b/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js @@ -0,0 +1,4 @@ +import React from 'react' +export default { + React, +} diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js b/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js new file mode 100644 index 0000000..3346f3b --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js @@ -0,0 +1,15 @@ +'use strict' + +// During bootstrap, we write requires at top of this file which looks +// basically like: +// module.exports = [ +// { +// plugin: require("/path/to/plugin1/gatsby-browser.js"), +// options: { ... }, +// }, +// { +// plugin: require("/path/to/plugin2/gatsby-browser.js"), +// options: { ... }, +// }, +// ] +module.exports = [] diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js b/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js new file mode 100644 index 0000000..45c9a81 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js @@ -0,0 +1,62 @@ +'use strict' + +const plugins = require(`./api-runner-browser-plugins`) + +const _require$publicLoader = require(`./loader`).publicLoader, + getResourcesForPathname = _require$publicLoader.getResourcesForPathname, + getResourcesForPathnameSync = + _require$publicLoader.getResourcesForPathnameSync, + getResourceURLsForPathname = _require$publicLoader.getResourceURLsForPathname + +exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => { + // Hooks for gatsby-cypress's API handler + if (process.env.CYPRESS_SUPPORT) { + if (window.___apiHandler) { + window.___apiHandler(api) + } else if (window.___resolvedAPIs) { + window.___resolvedAPIs.push(api) + } else { + window.___resolvedAPIs = [api] + } + } + + let results = plugins.map(plugin => { + if (!plugin.plugin[api]) { + return undefined + } + + args.getResourcesForPathnameSync = getResourcesForPathnameSync + args.getResourcesForPathname = getResourcesForPathname + args.getResourceURLsForPathname = getResourceURLsForPathname + const result = plugin.plugin[api](args, plugin.options) + + if (result && argTransform) { + args = argTransform({ + args, + result, + plugin, + }) + } + + return result + }) // Filter out undefined results. + + results = results.filter(result => typeof result !== `undefined`) + + if (results.length > 0) { + return results + } else if (defaultReturn) { + return [defaultReturn] + } else { + return [] + } +} + +exports.apiRunnerAsync = (api, args, defaultReturn) => + plugins.reduce( + (previous, next) => + next.plugin[api] + ? previous.then(() => next.plugin[api](args, next.options)) + : previous, + Promise.resolve() + ) diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js b/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js new file mode 100644 index 0000000..c41f965 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js @@ -0,0 +1,46 @@ +'use strict' + +// During bootstrap, we write requires at top of this file which looks like: +// var plugins = [ +// { +// plugin: require("/path/to/plugin1/gatsby-ssr.js"), +// options: { ... }, +// }, +// { +// plugin: require("/path/to/plugin2/gatsby-ssr.js"), +// options: { ... }, +// }, +// ] +const apis = require(`./api-ssr-docs`) // Run the specified API in any plugins that have implemented it + +module.exports = (api, args, defaultReturn, argTransform) => { + if (!apis[api]) { + console.log(`This API doesn't exist`, api) + } // Run each plugin in series. + // eslint-disable-next-line no-undef + + let results = plugins.map(plugin => { + if (!plugin.plugin[api]) { + return undefined + } + + const result = plugin.plugin[api](args, plugin.options) + + if (result && argTransform) { + args = argTransform({ + args, + result, + }) + } + + return result + }) // Filter out undefined results. + + results = results.filter(result => typeof result !== `undefined`) + + if (results.length > 0) { + return results + } else { + return [defaultReturn] + } +} diff --git a/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js b/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js new file mode 100644 index 0000000..e8e6686 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js @@ -0,0 +1,183 @@ +'use strict' + +/** + * Replace the default server renderer. This is useful for integration with + * Redux, css-in-js libraries, etc. that need custom setups for server + * rendering. + * @param {Object} $0 + * @param {function} $0.replaceBodyHTMLString Call this with the HTML string + * you render. **WARNING** if multiple plugins implement this API it's the + * last plugin that "wins". TODO implement an automated warning against this. + * @param {function} $0.setHeadComponents Takes an array of components as its + * first argument which are added to the `headComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setHtmlAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setBodyAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setPreBodyComponents Takes an array of components as its + * first argument which are added to the `preBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setPostBodyComponents Takes an array of components as its + * first argument which are added to the `postBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setBodyProps Takes an object of data which + * is merged with other body props and passed to `html.js` as `bodyProps`. + * @param {Object} pluginOptions + * @example + * // From gatsby-plugin-glamor + * const { renderToString } = require("react-dom/server") + * const inline = require("glamor-inline") + * + * exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { + * const bodyHTML = renderToString(bodyComponent) + * const inlinedHTML = inline(bodyHTML) + * + * replaceBodyHTMLString(inlinedHTML) + * } + */ +exports.replaceRenderer = true +/** + * Called after every page Gatsby server renders while building HTML so you can + * set head and body components to be rendered in your `html.js`. + * + * Gatsby does a two-pass render for HTML. It loops through your pages first + * rendering only the body and then takes the result body HTML string and + * passes it as the `body` prop to your `html.js` to complete the render. + * + * It's often handy to be able to send custom components to your `html.js`. + * For example, it's a very common pattern for React.js libraries that + * support server rendering to pull out data generated during the render to + * add to your HTML. + * + * Using this API over [`replaceRenderer`](#replaceRenderer) is preferable as + * multiple plugins can implement this API where only one plugin can take + * over server rendering. However, if your plugin requires taking over server + * rendering then that's the one to + * use + * @param {Object} $0 + * @param {string} $0.pathname The pathname of the page currently being rendered. + * @param {function} $0.setHeadComponents Takes an array of components as its + * first argument which are added to the `headComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setHtmlAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setBodyAttributes Takes an object of props which will + * spread into the `` component. + * @param {function} $0.setPreBodyComponents Takes an array of components as its + * first argument which are added to the `preBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setPostBodyComponents Takes an array of components as its + * first argument which are added to the `postBodyComponents` array which is passed + * to the `html.js` component. + * @param {function} $0.setBodyProps Takes an object of data which + * is merged with other body props and passed to `html.js` as `bodyProps`. + * @param {Object} pluginOptions + * @example + * const { Helmet } = require("react-helmet") + * + * exports.onRenderBody = ( + * { setHeadComponents, setHtmlAttributes, setBodyAttributes }, + * pluginOptions + * ) => { + * const helmet = Helmet.renderStatic() + * setHtmlAttributes(helmet.htmlAttributes.toComponent()) + * setBodyAttributes(helmet.bodyAttributes.toComponent()) + * setHeadComponents([ + * helmet.title.toComponent(), + * helmet.link.toComponent(), + * helmet.meta.toComponent(), + * helmet.noscript.toComponent(), + * helmet.script.toComponent(), + * helmet.style.toComponent(), + * ]) + * } + */ + +exports.onRenderBody = true +/** + * Called after every page Gatsby server renders while building HTML so you can + * replace head components to be rendered in your `html.js`. This is useful if + * you need to reorder scripts or styles added by other plugins. + * @param {Object} $0 + * @param {Array} $0.getHeadComponents Returns the current `headComponents` array. + * @param {function} $0.replaceHeadComponents Takes an array of components as its + * first argument which replace the `headComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Array} $0.getPreBodyComponents Returns the current `preBodyComponents` array. + * @param {function} $0.replacePreBodyComponents Takes an array of components as its + * first argument which replace the `preBodyComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Array} $0.getPostBodyComponents Returns the current `postBodyComponents` array. + * @param {function} $0.replacePostBodyComponents Takes an array of components as its + * first argument which replace the `postBodyComponents` array which is passed + * to the `html.js` component. **WARNING** if multiple plugins implement this + * API it's the last plugin that "wins". + * @param {Object} pluginOptions + * @example + * // Move Typography.js styles to the top of the head section so they're loaded first. + * exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => { + * const headComponents = getHeadComponents() + * headComponents.sort((x, y) => { + * if (x.key === 'TypographyStyle') { + * return -1 + * } else if (y.key === 'TypographyStyle') { + * return 1 + * } + * return 0 + * }) + * replaceHeadComponents(headComponents) + * } + */ + +exports.onPreRenderHTML = true +/** + * Allow a plugin to wrap the page element. + * + * This is useful for setting wrapper component around pages that won't get + * unmounted on page change. For setting Provider components use [wrapRootElement](#wrapRootElement). + * + * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapPageElement) + * @param {object} $0 + * @param {ReactNode} $0.element The "Page" React Element built by Gatsby. + * @param {object} $0.props Props object used by page. + * @example + * import React from "react" + * import Layout from "./src/components/layout" + * + * export const wrapPageElement = ({ element, props }) => { + * // props provide same data to Layout as Page element will get + * // including location, data, etc - you don't need to pass it + * return {element} + * } + */ + +exports.wrapPageElement = true +/** + * Allow a plugin to wrap the root element. + * + * This is useful to setup any Providers component that will wrap your application. + * For setting persistent UI elements around pages use [wrapPageElement](#wrapPageElement). + * + * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapRootElement) + * @param {object} $0 + * @param {ReactNode} $0.element The "Root" React Element built by Gatsby. + * @example + * import React from "react" + * import { Provider } from "react-redux" + * + * import createStore from "./src/state/createStore" + * const store = createStore() + * + * export const wrapRootElement = ({ element }) => { + * return ( + * + * {element} + * + * ) + * } + */ + +exports.wrapRootElement = true diff --git a/packages/gatsby-theme/.cache/commonjs/app.js b/packages/gatsby-theme/.cache/commonjs/app.js new file mode 100644 index 0000000..7048393 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/app.js @@ -0,0 +1,103 @@ +'use strict' + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +var _react = _interopRequireDefault(require('react')) + +var _reactDom = _interopRequireDefault(require('react-dom')) + +var _domready = _interopRequireDefault(require('@mikaelkristiansson/domready')) + +var _socketIo = _interopRequireDefault(require('./socketIo')) + +var _emitter = _interopRequireDefault(require('./emitter')) + +var _apiRunnerBrowser = require('./api-runner-browser') + +var _loader = _interopRequireWildcard(require('./loader')) + +var _syncRequires = _interopRequireDefault(require('./sync-requires')) + +var _pages = _interopRequireDefault(require('./pages.json')) + +window.___emitter = _emitter.default +;(0, _loader.setApiRunnerForLoader)(_apiRunnerBrowser.apiRunner) // Let the site/plugins run code very early. + +;(0, _apiRunnerBrowser.apiRunnerAsync)(`onClientEntry`).then(() => { + // Hook up the client to socket.io on server + const socket = (0, _socketIo.default)() + + if (socket) { + socket.on(`reload`, () => { + window.location.reload() + }) + } + /** + * Service Workers are persistent by nature. They stick around, + * serving a cached version of the site if they aren't removed. + * This is especially frustrating when you need to test the + * production build on your local machine. + * + * Let's unregister the service workers in development, and tidy up a few errors. + */ + + if (supportsServiceWorkers(location, navigator)) { + navigator.serviceWorker.getRegistrations().then(registrations => { + for ( + var _iterator = registrations, + _isArray = Array.isArray(_iterator), + _i = 0, + _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); + ; + + ) { + var _ref + + if (_isArray) { + if (_i >= _iterator.length) break + _ref = _iterator[_i++] + } else { + _i = _iterator.next() + if (_i.done) break + _ref = _i.value + } + + let registration = _ref + registration.unregister() + } + }) + } + + const rootElement = document.getElementById(`___gatsby`) + const renderer = (0, _apiRunnerBrowser.apiRunner)( + `replaceHydrateFunction`, + undefined, + _reactDom.default.render + )[0] + + _loader.default.addPagesArray(_pages.default) + + _loader.default.addDevRequires(_syncRequires.default) + + _loader.default.getResourcesForPathname(window.location.pathname).then(() => { + const preferDefault = m => (m && m.default) || m + + let Root = preferDefault(require(`./root`)) + ;(0, _domready.default)(() => { + renderer(_react.default.createElement(Root, null), rootElement, () => { + ;(0, _loader.postInitialRenderWork)() + ;(0, _apiRunnerBrowser.apiRunner)(`onInitialClientRender`) + }) + }) + }) +}) + +function supportsServiceWorkers(location, navigator) { + if (location.hostname === `localhost` || location.protocol === `https:`) { + return `serviceWorker` in navigator + } + + return false +} diff --git a/packages/gatsby-theme/.cache/commonjs/create-react-context.js b/packages/gatsby-theme/.cache/commonjs/create-react-context.js new file mode 100644 index 0000000..a21f187 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/create-react-context.js @@ -0,0 +1,11 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _default = _react.default.createContext +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/default-html.js b/packages/gatsby-theme/.cache/commonjs/default-html.js new file mode 100644 index 0000000..78880d9 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/default-html.js @@ -0,0 +1,63 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = HTML + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +function HTML(props) { + return _react.default.createElement( + 'html', + props.htmlAttributes, + _react.default.createElement( + 'head', + null, + _react.default.createElement('meta', { + charSet: 'utf-8', + }), + _react.default.createElement('meta', { + httpEquiv: 'x-ua-compatible', + content: 'ie=edge', + }), + _react.default.createElement('meta', { + name: 'viewport', + content: 'width=device-width, initial-scale=1, shrink-to-fit=no', + }), + props.headComponents + ), + _react.default.createElement( + 'body', + props.bodyAttributes, + props.preBodyComponents, + _react.default.createElement( + 'noscript', + { + key: 'noscript', + id: 'gatsby-noscript', + }, + 'This app works best with JavaScript enabled.' + ), + _react.default.createElement('div', { + key: `body`, + id: '___gatsby', + dangerouslySetInnerHTML: { + __html: props.body, + }, + }), + props.postBodyComponents + ) + ) +} + +HTML.propTypes = { + htmlAttributes: _propTypes.default.object, + headComponents: _propTypes.default.array, + bodyAttributes: _propTypes.default.object, + preBodyComponents: _propTypes.default.array, + body: _propTypes.default.string, + postBodyComponents: _propTypes.default.array, +} diff --git a/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js b/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js new file mode 100644 index 0000000..c49bf48 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js @@ -0,0 +1,136 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _server = require('react-dom/server') + +var _lodash = require('lodash') + +var _apiRunnerSsr = _interopRequireDefault(require('./api-runner-ssr')) + +// import testRequireError from "./test-require-error" +// For some extremely mysterious reason, webpack adds the above module *after* +// this module so that when this code runs, testRequireError is undefined. +// So in the meantime, we'll just inline it. +const testRequireError = (moduleName, err) => { + const regex = new RegExp(`Error: Cannot find module\\s.${moduleName}`) + const firstLine = err.toString().split(`\n`)[0] + return regex.test(firstLine) +} + +let Html + +try { + Html = require(`../src/html`) +} catch (err) { + if (testRequireError(`../src/html`, err)) { + Html = require(`./default-html`) + } else { + console.log(`There was an error requiring "src/html.js"\n\n`, err, `\n\n`) + process.exit() + } +} + +Html = Html && Html.__esModule ? Html.default : Html + +var _default = (pagePath, callback) => { + let headComponents = [] + let htmlAttributes = {} + let bodyAttributes = {} + let preBodyComponents = [] + let postBodyComponents = [] + let bodyProps = {} + let htmlStr + + const setHeadComponents = components => { + headComponents = headComponents.concat(components) + } + + const setHtmlAttributes = attributes => { + htmlAttributes = (0, _lodash.merge)(htmlAttributes, attributes) + } + + const setBodyAttributes = attributes => { + bodyAttributes = (0, _lodash.merge)(bodyAttributes, attributes) + } + + const setPreBodyComponents = components => { + preBodyComponents = preBodyComponents.concat(components) + } + + const setPostBodyComponents = components => { + postBodyComponents = postBodyComponents.concat(components) + } + + const setBodyProps = props => { + bodyProps = (0, _lodash.merge)({}, bodyProps, props) + } + + const getHeadComponents = () => headComponents + + const replaceHeadComponents = components => { + headComponents = components + } + + const getPreBodyComponents = () => preBodyComponents + + const replacePreBodyComponents = components => { + preBodyComponents = components + } + + const getPostBodyComponents = () => postBodyComponents + + const replacePostBodyComponents = components => { + postBodyComponents = components + } + + ;(0, _apiRunnerSsr.default)(`onRenderBody`, { + setHeadComponents, + setHtmlAttributes, + setBodyAttributes, + setPreBodyComponents, + setPostBodyComponents, + setBodyProps, + }) + ;(0, _apiRunnerSsr.default)(`onPreRenderHTML`, { + getHeadComponents, + replaceHeadComponents, + getPreBodyComponents, + replacePreBodyComponents, + getPostBodyComponents, + replacePostBodyComponents, + }) + + const htmlElement = _react.default.createElement( + Html, + Object.assign({}, bodyProps, { + body: ``, + headComponents: headComponents.concat([ + _react.default.createElement('script', { + key: `io`, + src: '/socket.io/socket.io.js', + }), + ]), + htmlAttributes, + bodyAttributes, + preBodyComponents, + postBodyComponents: postBodyComponents.concat([ + _react.default.createElement('script', { + key: `commons`, + src: '/commons.js', + }), + ]), + }) + ) + + htmlStr = (0, _server.renderToStaticMarkup)(htmlElement) + htmlStr = `${htmlStr}` + callback(null, htmlStr) +} + +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/emitter.js b/packages/gatsby-theme/.cache/commonjs/emitter.js new file mode 100644 index 0000000..bc82dbb --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/emitter.js @@ -0,0 +1,12 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _mitt = _interopRequireDefault(require('mitt')) + +const emitter = (0, _mitt.default)() +var _default = emitter +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/ensure-resources.js b/packages/gatsby-theme/.cache/commonjs/ensure-resources.js new file mode 100644 index 0000000..877b4ab --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/ensure-resources.js @@ -0,0 +1,154 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _loader = _interopRequireDefault(require('./loader')) + +var _shallowCompare = _interopRequireDefault(require('shallow-compare')) + +let isInitialRender = true // Pass pathname in as prop. +// component will try fetching resources. If they exist, +// will just render, else will render null. +// It will also wait for pageResources +// before propagating location change to children. + +class EnsureResources extends _react.default.Component { + constructor(props) { + super() + let location = props.location + this.state = { + location: Object.assign({}, location), + pageResources: _loader.default.getResourcesForPathnameSync( + location.pathname + ), + } + } + + reloadPage(prevHref) { + // Do this, rather than simply `window.location.reload()`, so that + // pressing the back/forward buttons work - otherwise when pressing + // back, the browser will just change the URL and expect JS to handle + // the change, which won't always work since it might not be a Gatsby + // page. + const href = window.location.href + window.history.replaceState({}, ``, prevHref) + window.location.replace(href) + } + + static getDerivedStateFromProps({ location }, prevState) { + if (prevState.location !== location) { + const pageResources = _loader.default.getResourcesForPathnameSync( + location.pathname + ) + + return { + pageResources, + location: Object.assign({}, location), + } + } + + return null + } + + hasResources(pageResources) { + if (pageResources && pageResources.json) { + return true + } + + if (pageResources && process.env.NODE_ENV !== `production`) { + return true + } + + return false + } + + retryResources(nextProps) { + const pathname = nextProps.location.pathname + + if (!_loader.default.getResourcesForPathnameSync(pathname)) { + // Store the previous and next location before resolving resources + const prevLocation = this.props.location + this.nextLocation = nextProps.location // Page resources won't be set in cases where the browser back button + // or forward button is pushed as we can't wait as normal for resources + // to load before changing the page. + + _loader.default.getResourcesForPathname(pathname).then(pageResources => { + // The page may have changed since we started this, in which case doesn't update + if (this.nextLocation !== nextProps.location) { + return + } + + if (this.hasResources(pageResources)) { + this.setState({ + location: Object.assign({}, window.location), + pageResources, + }) + return + } // If we still don't have resources, reload the page. + // (This won't happen on initial render, since shouldComponentUpdate + // is only called when the component updates.) + + this.reloadPage(prevLocation.href) + }) + } + } + + shouldComponentUpdate(nextProps, nextState) { + // Always return false if we're missing resources. + if (!this.hasResources(nextState.pageResources)) { + this.retryResources(nextProps) + return false + } // Check if the component or json have changed. + + if (this.state.pageResources !== nextState.pageResources) { + return true + } + + if ( + this.state.pageResources.component !== nextState.pageResources.component + ) { + return true + } + + if (this.state.pageResources.json !== nextState.pageResources.json) { + return true + } // Check if location has changed on a page using internal routing + // via matchPath configuration. + + if ( + this.state.location.key !== nextState.location.key && + nextState.pageResources.page && + (nextState.pageResources.page.matchPath || + nextState.pageResources.page.path) + ) { + return true + } + + return (0, _shallowCompare.default)(this, nextProps, nextState) + } + + render() { + if (!this.hasResources(this.state.pageResources) && isInitialRender) { + window.___failedResources = true // prevent hydrating + + throw new Error(`Missing resources for ${this.state.location.pathname}`) + } + + isInitialRender = false + return this.props.children(this.state) + } +} + +EnsureResources.propTypes = { + location: _propTypes.default.object.isRequired, + pageResources: _propTypes.default.object, +} +var _default = EnsureResources +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js b/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js new file mode 100644 index 0000000..cb0bfc4 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js @@ -0,0 +1,52 @@ +'use strict' + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +exports.__esModule = true +exports.errorMap = exports.reportError = exports.clearError = void 0 + +var ErrorOverlay = _interopRequireWildcard(require('react-error-overlay')) + +// Report runtime errors +ErrorOverlay.startReportingRuntimeErrors({ + onError: () => {}, + filename: `/commons.js`, +}) +ErrorOverlay.setEditorHandler(errorLocation => + window.fetch( + `/__open-stack-frame-in-editor?fileName=` + + window.encodeURIComponent(errorLocation.fileName) + + `&lineNumber=` + + window.encodeURIComponent(errorLocation.lineNumber || 1) + ) +) +const errorMap = {} +exports.errorMap = errorMap + +const handleErrorOverlay = () => { + const errors = Object.values(errorMap) + + if (errors.length > 0) { + const errorMsg = errors.join(`\n\n`) + ErrorOverlay.reportBuildError(errorMsg) + } else { + ErrorOverlay.dismissBuildError() + } +} + +const clearError = errorID => { + delete errorMap[errorID] + handleErrorOverlay() +} + +exports.clearError = clearError + +const reportError = (errorID, error) => { + if (error) { + errorMap[errorID] = error + } + + handleErrorOverlay() +} + +exports.reportError = reportError diff --git a/packages/gatsby-theme/.cache/commonjs/find-page.js b/packages/gatsby-theme/.cache/commonjs/find-page.js new file mode 100644 index 0000000..4031364 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/find-page.js @@ -0,0 +1,61 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _utils = require('@reach/router/lib/utils') + +var _stripPrefix = _interopRequireDefault(require('./strip-prefix')) + +// TODO add tests especially for handling prefixed links. +const pageCache = {} + +var _default = (pages, pathPrefix = ``) => rawPathname => { + let pathname = decodeURIComponent(rawPathname) // Remove the pathPrefix from the pathname. + + let trimmedPathname = (0, _stripPrefix.default)(pathname, pathPrefix) // Remove any hashfragment + + if (trimmedPathname.split(`#`).length > 1) { + trimmedPathname = trimmedPathname + .split(`#`) + .slice(0, -1) + .join(``) + } // Remove search query + + if (trimmedPathname.split(`?`).length > 1) { + trimmedPathname = trimmedPathname + .split(`?`) + .slice(0, -1) + .join(``) + } + + if (pageCache[trimmedPathname]) { + return pageCache[trimmedPathname] + } + + let foundPage // Array.prototype.find is not supported in IE so we use this somewhat odd + // work around. + + pages.some(page => { + let pathToMatch = page.matchPath ? page.matchPath : page.path + + if ((0, _utils.match)(pathToMatch, trimmedPathname)) { + foundPage = page + pageCache[trimmedPathname] = page + return true + } // Finally, try and match request with default document. + + if ((0, _utils.match)(`${page.path}index.html`, trimmedPathname)) { + foundPage = page + pageCache[trimmedPathname] = page + return true + } + + return false + }) + return foundPage +} + +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js b/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js new file mode 100644 index 0000000..ac9665a --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js @@ -0,0 +1,98 @@ +'use strict' + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.graphql = graphql +exports.useStaticQuery = exports.StaticQuery = exports.StaticQueryContext = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _gatsbyLink = _interopRequireWildcard(require('gatsby-link')) + +exports.Link = _gatsbyLink.default +exports.withPrefix = _gatsbyLink.withPrefix +exports.navigate = _gatsbyLink.navigate +exports.push = _gatsbyLink.push +exports.replace = _gatsbyLink.replace +exports.navigateTo = _gatsbyLink.navigateTo +exports.parsePath = _gatsbyLink.parsePath + +var _publicPageRenderer = _interopRequireDefault( + require('./public-page-renderer') +) + +exports.PageRenderer = _publicPageRenderer.default + +const StaticQueryContext = _react.default.createContext({}) + +exports.StaticQueryContext = StaticQueryContext + +const StaticQuery = props => + _react.default.createElement( + StaticQueryContext.Consumer, + null, + staticQueryData => { + if ( + props.data || + (staticQueryData[props.query] && staticQueryData[props.query].data) + ) { + return (props.render || props.children)( + props.data ? props.data.data : staticQueryData[props.query].data + ) + } else { + return _react.default.createElement( + 'div', + null, + 'Loading (StaticQuery)' + ) + } + } + ) + +exports.StaticQuery = StaticQuery + +const useStaticQuery = query => { + if ( + typeof _react.default.useContext !== `function` && + process.env.NODE_ENV === `development` + ) { + throw new Error( + `You're likely using a version of React that doesn't support Hooks\n` + + `Please update React and ReactDOM to 16.8.0 or later to use the useStaticQuery hook.` + ) + } + + const context = _react.default.useContext(StaticQueryContext) + + if (context[query] && context[query].data) { + return context[query].data + } else { + throw new Error( + `The result of this StaticQuery could not be fetched.\n\n` + + `This is likely a bug in Gatsby and if refreshing the page does not fix it, ` + + `please open an issue in https://github.com/gatsbyjs/gatsby/issues` + ) + } +} + +exports.useStaticQuery = useStaticQuery +StaticQuery.propTypes = { + data: _propTypes.default.object, + query: _propTypes.default.string.isRequired, + render: _propTypes.default.func, + children: _propTypes.default.func, +} + +function graphql() { + throw new Error( + `It appears like Gatsby is misconfigured. Gatsby related \`graphql\` calls ` + + `are supposed to only be evaluated at compile time, and then compiled away,. ` + + `Unfortunately, something went wrong and the query was left in the compiled code.\n\n.` + + `Unless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby.` + ) +} diff --git a/packages/gatsby-theme/.cache/commonjs/json-store.js b/packages/gatsby-theme/.cache/commonjs/json-store.js new file mode 100644 index 0000000..786a21b --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/json-store.js @@ -0,0 +1,128 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _extends2 = _interopRequireDefault( + require('@babel/runtime/helpers/extends') +) + +var _objectWithoutPropertiesLoose2 = _interopRequireDefault( + require('@babel/runtime/helpers/objectWithoutPropertiesLoose') +) + +var _defineProperty2 = _interopRequireDefault( + require('@babel/runtime/helpers/defineProperty') +) + +var _react = _interopRequireDefault(require('react')) + +var _pageRenderer = _interopRequireDefault(require('./page-renderer')) + +var _gatsby = require('gatsby') + +var _socketIo = require('./socketIo') + +if (process.env.NODE_ENV === `production`) { + throw new Error( + `It appears like Gatsby is misconfigured. JSONStore is Gatsby internal ` + + `development-only component and should never be used in production.\n\n` + + `Unless your site has a complex or custom webpack/Gatsby ` + + `configuration this is likely a bug in Gatsby. ` + + `Please report this at https://github.com/gatsbyjs/gatsby/issues ` + + `with steps to reproduce this error.` + ) +} + +const getPathFromProps = props => + props.pageResources && props.pageResources.page + ? props.pageResources.page.path + : undefined + +class JSONStore extends _react.default.Component { + constructor(props) { + super(props) + ;(0, _defineProperty2.default)(this, 'handleMittEvent', (type, event) => { + this.setState({ + staticQueryData: (0, _socketIo.getStaticQueryData)(), + pageQueryData: (0, _socketIo.getPageQueryData)(), + }) + }) + this.state = { + staticQueryData: (0, _socketIo.getStaticQueryData)(), + pageQueryData: (0, _socketIo.getPageQueryData)(), + path: null, + } + } + + componentDidMount() { + ;(0, _socketIo.registerPath)(getPathFromProps(this.props)) + + ___emitter.on(`*`, this.handleMittEvent) + } + + componentWillUnmount() { + ;(0, _socketIo.unregisterPath)(this.state.path) + + ___emitter.off(`*`, this.handleMittEvent) + } + + static getDerivedStateFromProps(props, state) { + const newPath = getPathFromProps(props) + + if (newPath !== state.path) { + ;(0, _socketIo.unregisterPath)(state.path) + ;(0, _socketIo.registerPath)(newPath) + return { + path: newPath, + } + } + + return null + } + + shouldComponentUpdate(nextProps, nextState) { + // We want to update this component when: + // - location changed + // - page data for path changed + // - static query results changed + return ( + this.props.location !== nextProps.location || + this.state.path !== nextState.path || + this.state.pageQueryData[nextState.path] !== + nextState.pageQueryData[nextState.path] || + this.state.staticQueryData !== nextState.staticQueryData + ) + } + + render() { + const data = this.state.pageQueryData[getPathFromProps(this.props)] // eslint-disable-next-line + + const _this$props = this.props, + pages = _this$props.pages, + propsWithoutPages = (0, _objectWithoutPropertiesLoose2.default)( + _this$props, + ['pages'] + ) + + if (!data) { + return _react.default.createElement('div', null) + } + + return _react.default.createElement( + _gatsby.StaticQueryContext.Provider, + { + value: this.state.staticQueryData, + }, + _react.default.createElement( + _pageRenderer.default, + (0, _extends2.default)({}, propsWithoutPages, data) + ) + ) + } +} + +var _default = JSONStore +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/loader.js b/packages/gatsby-theme/.cache/commonjs/loader.js new file mode 100644 index 0000000..0f108c9 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/loader.js @@ -0,0 +1,449 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = exports.publicLoader = exports.setApiRunnerForLoader = exports.postInitialRenderWork = void 0 + +var _findPage = _interopRequireDefault(require('./find-page')) + +var _emitter = _interopRequireDefault(require('./emitter')) + +var _prefetch = _interopRequireDefault(require('./prefetch')) + +const preferDefault = m => (m && m.default) || m + +let devGetPageData +let inInitialRender = true +let hasFetched = Object.create(null) +let syncRequires = {} +let asyncRequires = {} +let jsonDataPaths = {} +let fetchHistory = [] +let fetchingPageResourceMapPromise = null +let fetchedPageResourceMap = false +/** + * Indicate if pages manifest is loaded + * - in production it is split to separate "pages-manifest" chunk that need to be lazy loaded, + * - in development it is part of single "common" chunk and is available from the start. + */ + +let hasPageResourceMap = process.env.NODE_ENV !== `production` +let apiRunner +const failedPaths = {} +const MAX_HISTORY = 5 +const jsonPromiseStore = {} + +if (process.env.NODE_ENV !== `production`) { + devGetPageData = require(`./socketIo`).getPageData +} +/** + * Fetch resource map (pages data and paths to json files with results of + * queries) + */ + +const fetchPageResourceMap = () => { + if (!fetchingPageResourceMapPromise) { + fetchingPageResourceMapPromise = new Promise(resolve => { + asyncRequires + .data() + .then(({ pages, dataPaths }) => { + // TODO — expose proper way to access this data from plugins. + // Need to come up with an API for plugins to access + // site info. + window.___dataPaths = dataPaths + queue.addPagesArray(pages) + queue.addDataPaths(dataPaths) + hasPageResourceMap = true + resolve((fetchedPageResourceMap = true)) + }) + .catch(e => { + console.warn( + `Failed to fetch pages manifest. Gatsby will reload on next navigation.` + ) // failed to grab pages metadata + // for now let's just resolve this - on navigation this will cause missing resources + // and will trigger page reload and then it will retry + // this can happen with service worker updates when webpack manifest points to old + // chunk that no longer exists on server + + resolve((fetchedPageResourceMap = true)) + }) + }) + } + + return fetchingPageResourceMapPromise +} + +const createJsonURL = jsonName => `${__PATH_PREFIX__}/static/d/${jsonName}.json` + +const createComponentUrls = componentChunkName => + window.___chunkMapping[componentChunkName].map( + chunk => __PATH_PREFIX__ + chunk + ) + +const fetchResource = resourceName => { + // Find resource + let resourceFunction + + if (resourceName.slice(0, 12) === `component---`) { + resourceFunction = asyncRequires.components[resourceName] + } else { + if (resourceName in jsonPromiseStore) { + resourceFunction = () => jsonPromiseStore[resourceName] + } else { + resourceFunction = () => { + const fetchPromise = new Promise((resolve, reject) => { + const url = createJsonURL(jsonDataPaths[resourceName]) + const req = new XMLHttpRequest() + req.open(`GET`, url, true) + req.withCredentials = true + + req.onreadystatechange = () => { + if (req.readyState == 4) { + if (req.status === 200) { + resolve(JSON.parse(req.responseText)) + } else { + delete jsonPromiseStore[resourceName] + reject() + } + } + } + + req.send(null) + }) + jsonPromiseStore[resourceName] = fetchPromise + return fetchPromise + } + } + } // Download the resource + + hasFetched[resourceName] = true + return new Promise(resolve => { + const fetchPromise = resourceFunction() + let failed = false + return fetchPromise + .catch(() => { + failed = true + }) + .then(component => { + fetchHistory.push({ + resource: resourceName, + succeeded: !failed, + }) + fetchHistory = fetchHistory.slice(-MAX_HISTORY) + resolve(component) + }) + }) +} + +const prefetchResource = resourceName => { + if (resourceName.slice(0, 12) === `component---`) { + return Promise.all( + createComponentUrls(resourceName).map(url => (0, _prefetch.default)(url)) + ) + } else { + const url = createJsonURL(jsonDataPaths[resourceName]) + return (0, _prefetch.default)(url) + } +} + +const getResourceModule = resourceName => + fetchResource(resourceName).then(preferDefault) + +const appearsOnLine = () => { + const isOnLine = navigator.onLine + + if (typeof isOnLine === `boolean`) { + return isOnLine + } // If no navigator.onLine support assume onLine if any of last N fetches succeeded + + const succeededFetch = fetchHistory.find(entry => entry.succeeded) + return !!succeededFetch +} + +const handleResourceLoadError = (path, message) => { + if (!failedPaths[path]) { + failedPaths[path] = message + } + + if ( + appearsOnLine() && + window.location.pathname.replace(/\/$/g, ``) !== path.replace(/\/$/g, ``) + ) { + window.location.pathname = path + } +} + +const onPrefetchPathname = pathname => { + if (!prefetchTriggered[pathname]) { + apiRunner(`onPrefetchPathname`, { + pathname, + }) + prefetchTriggered[pathname] = true + } +} + +const onPostPrefetchPathname = pathname => { + if (!prefetchCompleted[pathname]) { + apiRunner(`onPostPrefetchPathname`, { + pathname, + }) + prefetchCompleted[pathname] = true + } +} +/** + * Check if we should fallback to resources for 404 page if resources for a page are not found + * + * We can't do that when we don't have full pages manifest - we don't know if page exist or not if we don't have it. + * We also can't do that on initial render / mount in case we just can't load resources needed for first page. + * Not falling back to 404 resources will cause "EnsureResources" component to handle scenarios like this with + * potential reload + * @param {string} path Path to a page + */ + +const shouldFallbackTo404Resources = path => + (hasPageResourceMap || inInitialRender) && path !== `/404.html` // Note we're not actively using the path data atm. There +// could be future optimizations however around trying to ensure +// we load all resources for likely-to-be-visited paths. +// let pathArray = [] +// let pathCount = {} + +let findPage +let pathScriptsCache = {} +let prefetchTriggered = {} +let prefetchCompleted = {} +let disableCorePrefetching = false +const queue = { + addPagesArray: newPages => { + findPage = (0, _findPage.default)(newPages, __PATH_PREFIX__) + }, + addDevRequires: devRequires => { + syncRequires = devRequires + }, + addProdRequires: prodRequires => { + asyncRequires = prodRequires + }, + addDataPaths: dataPaths => { + jsonDataPaths = dataPaths + }, + // Hovering on a link is a very strong indication the user is going to + // click on it soon so let's start prefetching resources for this + // pathname. + hovering: path => { + queue.getResourcesForPathname(path) + }, + enqueue: path => { + if (!apiRunner) + console.error(`Run setApiRunnerForLoader() before enqueing paths`) // Skip prefetching if we know user is on slow or constrained connection + + if (`connection` in navigator) { + if ((navigator.connection.effectiveType || ``).includes(`2g`)) { + return false + } + + if (navigator.connection.saveData) { + return false + } + } // Tell plugins with custom prefetching logic that they should start + // prefetching this path. + + onPrefetchPathname(path) // If a plugin has disabled core prefetching, stop now. + + if (disableCorePrefetching.some(a => a)) { + return false + } // Check if the page exists. + + let page = findPage(path) // In production, we lazy load page metadata. If that + // hasn't been fetched yet, start fetching it now. + + if ( + process.env.NODE_ENV === `production` && + !page && + !fetchedPageResourceMap + ) { + // If page wasn't found check and we didn't fetch resources map for + // all pages, wait for fetch to complete and try find page again + return fetchPageResourceMap().then(() => queue.enqueue(path)) + } + + if (!page) { + return false + } + + if ( + process.env.NODE_ENV !== `production` && + process.env.NODE_ENV !== `test` + ) { + devGetPageData(page.path) + } // Prefetch resources. + + if (process.env.NODE_ENV === `production`) { + Promise.all([ + prefetchResource(page.jsonName), + prefetchResource(page.componentChunkName), + ]).then(() => { + // Tell plugins the path has been successfully prefetched + onPostPrefetchPathname(path) + }) + } + + return true + }, + getPage: pathname => findPage(pathname), + getResourceURLsForPathname: path => { + const page = findPage(path) + + if (page) { + return [ + ...createComponentUrls(page.componentChunkName), + createJsonURL(jsonDataPaths[page.jsonName]), + ] + } else { + return null + } + }, + getResourcesForPathnameSync: path => { + const page = findPage(path) + + if (page) { + return pathScriptsCache[page.path] + } else if (shouldFallbackTo404Resources(path)) { + return queue.getResourcesForPathnameSync(`/404.html`) + } else { + return null + } + }, + // Get resources (code/data) for a path. Fetches metdata first + // if necessary and then the code/data bundles. Used for prefetching + // and getting resources for page changes. + getResourcesForPathname: path => + new Promise((resolve, reject) => { + // Production code path + if (failedPaths[path]) { + handleResourceLoadError( + path, + `Previously detected load failure for "${path}"` + ) + reject() + return + } + + const page = findPage(path) // In production, we lazy load page metadata. If that + // hasn't been fetched yet, start fetching it now. + + if ( + !page && + !fetchedPageResourceMap && + process.env.NODE_ENV === `production` + ) { + // If page wasn't found check and we didn't fetch resources map for + // all pages, wait for fetch to complete and try to get resources again + fetchPageResourceMap().then(() => + resolve(queue.getResourcesForPathname(path)) + ) + return + } + + if (!page) { + if (shouldFallbackTo404Resources(path)) { + console.log(`A page wasn't found for "${path}"`) // Preload the custom 404 page + + resolve(queue.getResourcesForPathname(`/404.html`)) + return + } + + resolve() + return + } // Use the path from the page so the pathScriptsCache uses + // the normalized path. + + path = page.path // Check if it's in the cache already. + + if (pathScriptsCache[path]) { + _emitter.default.emit(`onPostLoadPageResources`, { + page, + pageResources: pathScriptsCache[path], + }) + + resolve(pathScriptsCache[path]) + return + } // Nope, we need to load resource(s) + + _emitter.default.emit(`onPreLoadPageResources`, { + path, + }) // In development we know the code is loaded already + // so we just return with it immediately. + + if (process.env.NODE_ENV !== `production`) { + const pageResources = { + component: syncRequires.components[page.componentChunkName], + page, // Add to the cache. + } + pathScriptsCache[path] = pageResources + devGetPageData(page.path).then(pageData => { + _emitter.default.emit(`onPostLoadPageResources`, { + page, + pageResources, + }) // Tell plugins the path has been successfully prefetched + + onPostPrefetchPathname(path) + resolve(pageResources) + }) + } else { + Promise.all([ + getResourceModule(page.componentChunkName), + getResourceModule(page.jsonName), + ]).then(([component, json]) => { + if (!(component && json)) { + resolve(null) + return + } + + const pageResources = { + component, + json, + page, + } + pageResources.page.jsonURL = createJsonURL( + jsonDataPaths[page.jsonName] + ) + pathScriptsCache[path] = pageResources + resolve(pageResources) + + _emitter.default.emit(`onPostLoadPageResources`, { + page, + pageResources, + }) // Tell plugins the path has been successfully prefetched + + onPostPrefetchPathname(path) + }) + } + }), +} + +const postInitialRenderWork = () => { + inInitialRender = false + + if (process.env.NODE_ENV === `production`) { + // We got all resources needed for first mount, + // we can fetch resources for all pages. + fetchPageResourceMap() + } +} + +exports.postInitialRenderWork = postInitialRenderWork + +const setApiRunnerForLoader = runner => { + apiRunner = runner + disableCorePrefetching = apiRunner(`disableCorePrefetching`) +} + +exports.setApiRunnerForLoader = setApiRunnerForLoader +const publicLoader = { + getResourcesForPathname: queue.getResourcesForPathname, + getResourceURLsForPathname: queue.getResourceURLsForPathname, + getResourcesForPathnameSync: queue.getResourcesForPathnameSync, +} +exports.publicLoader = publicLoader +var _default = queue +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/navigation.js b/packages/gatsby-theme/.cache/commonjs/navigation.js new file mode 100644 index 0000000..8d0eca2 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/navigation.js @@ -0,0 +1,199 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.init = init +exports.shouldUpdateScroll = shouldUpdateScroll +exports.RouteUpdates = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _loader = _interopRequireDefault(require('./loader')) + +var _redirects = _interopRequireDefault(require('./redirects.json')) + +var _apiRunnerBrowser = require('./api-runner-browser') + +var _emitter = _interopRequireDefault(require('./emitter')) + +var _router = require('@reach/router') + +var _gatsbyLink = require('gatsby-link') + +// Convert to a map for faster lookup in maybeRedirect() +const redirectMap = _redirects.default.reduce((map, redirect) => { + map[redirect.fromPath] = redirect + return map +}, {}) + +function maybeRedirect(pathname) { + const redirect = redirectMap[pathname] + + if (redirect != null) { + if (process.env.NODE_ENV !== `production`) { + const pageResources = _loader.default.getResourcesForPathnameSync( + pathname + ) + + if (pageResources != null) { + console.error( + `The route "${pathname}" matches both a page and a redirect; this is probably not intentional.` + ) + } + } + + window.___replace(redirect.toPath) + + return true + } else { + return false + } +} + +const onPreRouteUpdate = (location, prevLocation) => { + if (!maybeRedirect(location.pathname)) { + ;(0, _apiRunnerBrowser.apiRunner)(`onPreRouteUpdate`, { + location, + prevLocation, + }) + } +} + +const onRouteUpdate = (location, prevLocation) => { + if (!maybeRedirect(location.pathname)) { + ;(0, _apiRunnerBrowser.apiRunner)(`onRouteUpdate`, { + location, + prevLocation, + }) // Temp hack while awaiting https://github.com/reach/router/issues/119 + + window.__navigatingToLink = false + } +} + +const navigate = (to, options = {}) => { + // Temp hack while awaiting https://github.com/reach/router/issues/119 + if (!options.replace) { + window.__navigatingToLink = true + } + + let _parsePath = (0, _gatsbyLink.parsePath)(to), + pathname = _parsePath.pathname + + const redirect = redirectMap[pathname] // If we're redirecting, just replace the passed in pathname + // to the one we want to redirect to. + + if (redirect) { + to = redirect.toPath + pathname = (0, _gatsbyLink.parsePath)(to).pathname + } // If we had a service worker update, no matter the path, reload window and + // reset the pathname whitelist + + if (window.___swUpdated) { + window.location = pathname + return + } // Start a timer to wait for a second before transitioning and showing a + // loader in case resources aren't around yet. + + const timeoutId = setTimeout(() => { + _emitter.default.emit(`onDelayedLoadPageResources`, { + pathname, + }) + + ;(0, _apiRunnerBrowser.apiRunner)(`onRouteUpdateDelayed`, { + location: window.location, + }) + }, 1000) + + _loader.default.getResourcesForPathname(pathname).then(pageResources => { + ;(0, _router.navigate)(to, options) + clearTimeout(timeoutId) + }) +} + +function shouldUpdateScroll(prevRouterProps, { location }) { + const pathname = location.pathname, + hash = location.hash + const results = (0, _apiRunnerBrowser.apiRunner)(`shouldUpdateScroll`, { + prevRouterProps, + // `pathname` for backwards compatibility + pathname, + routerProps: { + location, + }, + getSavedScrollPosition: args => this._stateStorage.read(args), + }) + + if (results.length > 0) { + return results[0] + } + + if (prevRouterProps) { + const oldPathname = prevRouterProps.location.pathname + + if (oldPathname === pathname) { + // Scroll to element if it exists, if it doesn't, or no hash is provided, + // scroll to top. + return hash ? hash.slice(1) : [0, 0] + } + } + + return true +} + +function init() { + // Temp hack while awaiting https://github.com/reach/router/issues/119 + window.__navigatingToLink = false + window.___loader = _loader.default + + window.___push = to => + navigate(to, { + replace: false, + }) + + window.___replace = to => + navigate(to, { + replace: true, + }) + + window.___navigate = (to, options) => navigate(to, options) // Check for initial page-load redirect + + maybeRedirect(window.location.pathname) +} // Fire on(Pre)RouteUpdate APIs + +class RouteUpdates extends _react.default.Component { + constructor(props) { + super(props) + onPreRouteUpdate(props.location, null) + } + + componentDidMount() { + onRouteUpdate(this.props.location, null) + } + + componentDidUpdate(prevProps, prevState, shouldFireRouteUpdate) { + if (shouldFireRouteUpdate) { + onRouteUpdate(this.props.location, prevProps.location) + } + } + + getSnapshotBeforeUpdate(prevProps) { + if (this.props.location.pathname !== prevProps.location.pathname) { + onPreRouteUpdate(this.props.location, prevProps.location) + return true + } + + return false + } + + render() { + return this.props.children + } +} + +exports.RouteUpdates = RouteUpdates +RouteUpdates.propTypes = { + location: _propTypes.default.object.isRequired, +} diff --git a/packages/gatsby-theme/.cache/commonjs/page-renderer.js b/packages/gatsby-theme/.cache/commonjs/page-renderer.js new file mode 100644 index 0000000..8053b41 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/page-renderer.js @@ -0,0 +1,67 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireWildcard(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _loader = require('./loader') + +var _apiRunnerBrowser = require('./api-runner-browser') + +// Renders page +class PageRenderer extends _react.default.Component { + render() { + const props = Object.assign({}, this.props, { + pathContext: this.props.pageContext, + }) + + const _apiRunner = (0, _apiRunnerBrowser.apiRunner)( + `replaceComponentRenderer`, + { + props: this.props, + loader: _loader.publicLoader, + } + ), + replacementElement = _apiRunner[0] + + const pageElement = + replacementElement || + (0, _react.createElement)( + this.props.pageResources.component, + Object.assign({}, props, { + key: this.props.pageResources.page.path, + }) + ) + const wrappedPage = (0, _apiRunnerBrowser.apiRunner)( + `wrapPageElement`, + { + element: pageElement, + props, + }, + pageElement, + ({ result }) => { + return { + element: result, + props, + } + } + ).pop() + return wrappedPage + } +} + +PageRenderer.propTypes = { + location: _propTypes.default.object.isRequired, + pageResources: _propTypes.default.object.isRequired, + data: _propTypes.default.object, + pageContext: _propTypes.default.object.isRequired, +} +var _default = PageRenderer +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/prefetch.js b/packages/gatsby-theme/.cache/commonjs/prefetch.js new file mode 100644 index 0000000..1515ac5 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/prefetch.js @@ -0,0 +1,83 @@ +'use strict' + +exports.__esModule = true +exports.default = void 0 + +const support = function support(feature) { + if (typeof document === `undefined`) { + return false + } + + const fakeLink = document.createElement(`link`) + + try { + if (fakeLink.relList && typeof fakeLink.relList.supports === `function`) { + return fakeLink.relList.supports(feature) + } + } catch (err) { + return false + } + + return false +} + +const linkPrefetchStrategy = function linkPrefetchStrategy(url) { + return new Promise((resolve, reject) => { + if (typeof document === `undefined`) { + reject() + return + } + + const link = document.createElement(`link`) + link.setAttribute(`rel`, `prefetch`) + link.setAttribute(`href`, url) + link.onload = resolve + link.onerror = reject + const parentElement = + document.getElementsByTagName(`head`)[0] || + document.getElementsByName(`script`)[0].parentNode + parentElement.appendChild(link) + }) +} + +const xhrPrefetchStrategy = function xhrPrefetchStrategy(url) { + return new Promise((resolve, reject) => { + const req = new XMLHttpRequest() + req.open(`GET`, url, true) + req.withCredentials = true + + req.onload = () => { + if (req.status === 200) { + resolve() + } else { + reject() + } + } + + req.send(null) + }) +} + +const supportedPrefetchStrategy = support(`prefetch`) + ? linkPrefetchStrategy + : xhrPrefetchStrategy +const preFetched = {} + +const prefetch = function prefetch(url) { + return new Promise(resolve => { + if (preFetched[url]) { + resolve() + return + } + + supportedPrefetchStrategy(url) + .then(() => { + resolve() + preFetched[url] = true + }) + .catch(() => {}) // 404s are logged to the console anyway + }) +} + +var _default = prefetch +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/production-app.js b/packages/gatsby-theme/.cache/commonjs/production-app.js new file mode 100644 index 0000000..9c6a697 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/production-app.js @@ -0,0 +1,168 @@ +'use strict' + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +var _extends2 = _interopRequireDefault( + require('@babel/runtime/helpers/extends') +) + +var _apiRunnerBrowser = require('./api-runner-browser') + +var _react = _interopRequireWildcard(require('react')) + +var _reactDom = _interopRequireDefault(require('react-dom')) + +var _router = require('@reach/router') + +var _utils = require('@reach/router/lib/utils') + +var _gatsbyReactRouterScroll = require('gatsby-react-router-scroll') + +var _domready = _interopRequireDefault(require('@mikaelkristiansson/domready')) + +var _navigation = require('./navigation') + +var _emitter = _interopRequireDefault(require('./emitter')) + +var _pageRenderer = _interopRequireDefault(require('./page-renderer')) + +var _asyncRequires = _interopRequireDefault(require('./async-requires')) + +var _loader = _interopRequireWildcard(require('./loader')) + +var _ensureResources = _interopRequireDefault(require('./ensure-resources')) + +window.asyncRequires = _asyncRequires.default +window.___emitter = _emitter.default +window.___loader = _loader.default + +_loader.default.addPagesArray([window.page]) + +_loader.default.addDataPaths({ + [window.page.jsonName]: window.dataPath, +}) + +_loader.default.addProdRequires(_asyncRequires.default) + +;(0, _loader.setApiRunnerForLoader)(_apiRunnerBrowser.apiRunner) +;(0, _navigation.init)() // Let the site/plugins run code very early. + +;(0, _apiRunnerBrowser.apiRunnerAsync)(`onClientEntry`).then(() => { + // Let plugins register a service worker. The plugin just needs + // to return true. + if ((0, _apiRunnerBrowser.apiRunner)(`registerServiceWorker`).length > 0) { + require(`./register-service-worker`) + } + + class RouteHandler extends _react.default.Component { + render() { + let location = this.props.location + return _react.default.createElement( + _ensureResources.default, + { + location: location, + }, + ({ pageResources, location }) => + _react.default.createElement( + _navigation.RouteUpdates, + { + location: location, + }, + _react.default.createElement( + _gatsbyReactRouterScroll.ScrollContext, + { + location: location, + shouldUpdateScroll: _navigation.shouldUpdateScroll, + }, + _react.default.createElement( + _pageRenderer.default, + (0, _extends2.default)( + {}, + this.props, + { + location: location, + pageResources: pageResources, + }, + pageResources.json + ) + ) + ) + ) + ) + } + } + + const _window = window, + page = _window.page, + browserLoc = _window.location + + if ( + // Make sure the window.page object is defined + page && // The canonical path doesn't match the actual path (i.e. the address bar) + __PATH_PREFIX__ + page.path !== browserLoc.pathname && // ...and if matchPage is specified, it also doesn't match the actual path + (!page.matchPath || + !(0, _utils.match)( + __PATH_PREFIX__ + page.matchPath, + browserLoc.pathname + )) && // Ignore 404 pages, since we want to keep the same URL + page.path !== `/404.html` && + !page.path.match(/^\/404\/?$/) && // Also ignore the offline shell (since when using the offline plugin, all + // pages have this canonical path) + !page.path.match(/^\/offline-plugin-app-shell-fallback\/?$/) + ) { + ;(0, _router.navigate)( + __PATH_PREFIX__ + page.path + browserLoc.search + browserLoc.hash, + { + replace: true, + } + ) + } + + _loader.default.getResourcesForPathname(browserLoc.pathname).then(() => { + const Root = () => + (0, _react.createElement)( + _router.Router, + { + basepath: __PATH_PREFIX__, + }, + (0, _react.createElement)(RouteHandler, { + path: `/*`, + }) + ) + + const WrappedRoot = (0, _apiRunnerBrowser.apiRunner)( + `wrapRootElement`, + { + element: _react.default.createElement(Root, null), + }, + _react.default.createElement(Root, null), + ({ result }) => { + return { + element: result, + } + } + ).pop() + + let NewRoot = () => WrappedRoot + + const renderer = (0, _apiRunnerBrowser.apiRunner)( + `replaceHydrateFunction`, + undefined, + _reactDom.default.hydrate + )[0] + ;(0, _domready.default)(() => { + renderer( + _react.default.createElement(NewRoot, null), + typeof window !== `undefined` + ? document.getElementById(`___gatsby`) + : void 0, + () => { + ;(0, _loader.postInitialRenderWork)() + ;(0, _apiRunnerBrowser.apiRunner)(`onInitialClientRender`) + } + ) + }) + }) +}) diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js new file mode 100644 index 0000000..b5bc770 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js @@ -0,0 +1,36 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _pages = _interopRequireDefault(require('./pages.json')) + +var _loader = _interopRequireDefault(require('./loader')) + +var _jsonStore = _interopRequireDefault(require('./json-store')) + +const DevPageRenderer = ({ location }) => { + const pageResources = _loader.default.getResourcesForPathnameSync( + location.pathname + ) + + return _react.default.createElement(_jsonStore.default, { + pages: _pages.default, + location, + pageResources, + }) +} + +DevPageRenderer.propTypes = { + location: _propTypes.default.shape({ + pathname: _propTypes.default.string.isRequired, + }).isRequired, +} +var _default = DevPageRenderer +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js new file mode 100644 index 0000000..ec5a2cc --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js @@ -0,0 +1,39 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _react = _interopRequireDefault(require('react')) + +var _propTypes = _interopRequireDefault(require('prop-types')) + +var _pageRenderer = _interopRequireDefault(require('./page-renderer')) + +var _loader = _interopRequireDefault(require('./loader')) + +const ProdPageRenderer = ({ location }) => { + const pageResources = _loader.default.getResourcesForPathnameSync( + location.pathname + ) + + return _react.default.createElement( + _pageRenderer.default, + Object.assign( + { + location, + pageResources, + }, + pageResources.json + ) + ) +} + +ProdPageRenderer.propTypes = { + location: _propTypes.default.shape({ + pathname: _propTypes.default.string.isRequired, + }).isRequired, +} +var _default = ProdPageRenderer +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js new file mode 100644 index 0000000..8d56031 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js @@ -0,0 +1,11 @@ +'use strict' + +const preferDefault = m => (m && m.default) || m + +if (process.env.BUILD_STAGE === `develop`) { + module.exports = preferDefault(require(`./public-page-renderer-dev`)) +} else if (process.env.BUILD_STAGE === `build-javascript`) { + module.exports = preferDefault(require(`./public-page-renderer-prod`)) +} else { + module.exports = () => null +} diff --git a/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js b/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js new file mode 100644 index 0000000..6123b1d --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js @@ -0,0 +1,3 @@ +'use strict' + +exports.polyfill = Component => Component diff --git a/packages/gatsby-theme/.cache/commonjs/register-service-worker.js b/packages/gatsby-theme/.cache/commonjs/register-service-worker.js new file mode 100644 index 0000000..4ef7430 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/register-service-worker.js @@ -0,0 +1,77 @@ +'use strict' + +var _apiRunnerBrowser = require('./api-runner-browser') + +if ( + window.location.protocol !== `https:` && + window.location.hostname !== `localhost` +) { + console.error( + `Service workers can only be used over HTTPS, or on localhost for development` + ) +} else if (`serviceWorker` in navigator) { + navigator.serviceWorker + .register(`${__PATH_PREFIX__}/sw.js`) + .then(function(reg) { + reg.addEventListener(`updatefound`, () => { + ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerUpdateFound`, { + serviceWorker: reg, + }) // The updatefound event implies that reg.installing is set; see + // https://w3c.github.io/ServiceWorker/#service-worker-registration-updatefound-event + + const installingWorker = reg.installing + console.log(`installingWorker`, installingWorker) + installingWorker.addEventListener(`statechange`, () => { + switch (installingWorker.state) { + case `installed`: + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and the fresh content will + // have been added to the cache. + // We set a flag so Gatsby Link knows to refresh the page on next navigation attempt + window.___swUpdated = true // We call the onServiceWorkerUpdateReady API so users can show update prompts. + + ;(0, _apiRunnerBrowser.apiRunner)( + `onServiceWorkerUpdateReady`, + { + serviceWorker: reg, + } + ) // If resources failed for the current page, reload. + + if (window.___failedResources) { + console.log(`resources failed, SW updated - reloading`) + window.location.reload() + } + } else { + // At this point, everything has been precached. + // It's the perfect time to display a "Content is cached for offline use." message. + console.log(`Content is now available offline!`) // Post to service worker that install is complete. + // Delay to allow time for the event listener to be added -- + // otherwise fetch is called too soon and resources aren't cached. + + ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerInstalled`, { + serviceWorker: reg, + }) + } + + break + + case `redundant`: + console.error(`The installing service worker became redundant.`) + ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerRedundant`, { + serviceWorker: reg, + }) + break + + case `activated`: + ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerActive`, { + serviceWorker: reg, + }) + break + } + }) + }) + }) + .catch(function(e) { + console.error(`Error during service worker registration:`, e) + }) +} diff --git a/packages/gatsby-theme/.cache/commonjs/root.js b/packages/gatsby-theme/.cache/commonjs/root.js new file mode 100644 index 0000000..89c5342 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/root.js @@ -0,0 +1,183 @@ +'use strict' + +var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _extends2 = _interopRequireDefault( + require('@babel/runtime/helpers/extends') +) + +var _react = _interopRequireWildcard(require('react')) + +var _router = require('@reach/router') + +var _gatsbyReactRouterScroll = require('gatsby-react-router-scroll') + +var _navigation = require('./navigation') + +var _apiRunnerBrowser = require('./api-runner-browser') + +var _syncRequires = _interopRequireDefault(require('./sync-requires')) + +var _pages = _interopRequireDefault(require('./pages.json')) + +var _loader = _interopRequireDefault(require('./loader')) + +var _jsonStore = _interopRequireDefault(require('./json-store')) + +var _ensureResources = _interopRequireDefault(require('./ensure-resources')) + +var _errorOverlayHandler = require('./error-overlay-handler') + +if (window.__webpack_hot_middleware_reporter__ !== undefined) { + const overlayErrorID = `webpack` // Report build errors + + window.__webpack_hot_middleware_reporter__.useCustomOverlay({ + showProblems(type, obj) { + if (type !== `errors`) { + ;(0, _errorOverlayHandler.clearError)(overlayErrorID) + return + } + + ;(0, _errorOverlayHandler.reportError)(overlayErrorID, obj[0]) + }, + + clear() { + ;(0, _errorOverlayHandler.clearError)(overlayErrorID) + }, + }) +} + +;(0, _navigation.init)() + +class RouteHandler extends _react.default.Component { + render() { + let location = this.props.location // check if page exists - in dev pages are sync loaded, it's safe to use + // loader.getPage + + let page = _loader.default.getPage(location.pathname) + + if (page) { + return _react.default.createElement( + _ensureResources.default, + { + location: location, + }, + locationAndPageResources => + _react.default.createElement( + _navigation.RouteUpdates, + { + location: location, + }, + _react.default.createElement( + _gatsbyReactRouterScroll.ScrollContext, + { + location: location, + shouldUpdateScroll: _navigation.shouldUpdateScroll, + }, + _react.default.createElement( + _jsonStore.default, + (0, _extends2.default)( + { + pages: _pages.default, + }, + this.props, + locationAndPageResources + ) + ) + ) + ) + ) + } else { + const dev404Page = _pages.default.find(p => + /^\/dev-404-page\/?$/.test(p.path) + ) + + const Dev404Page = + _syncRequires.default.components[dev404Page.componentChunkName] + + if (!_loader.default.getPage(`/404.html`)) { + return _react.default.createElement( + _navigation.RouteUpdates, + { + location: location, + }, + _react.default.createElement( + Dev404Page, + (0, _extends2.default)( + { + pages: _pages.default, + }, + this.props + ) + ) + ) + } + + return _react.default.createElement( + _ensureResources.default, + { + location: location, + }, + locationAndPageResources => + _react.default.createElement( + _navigation.RouteUpdates, + { + location: location, + }, + _react.default.createElement( + Dev404Page, + (0, _extends2.default)( + { + pages: _pages.default, + custom404: _react.default.createElement( + _jsonStore.default, + (0, _extends2.default)( + { + pages: _pages.default, + }, + this.props, + locationAndPageResources + ) + ), + }, + this.props + ) + ) + ) + ) + } + } +} + +const Root = () => + (0, _react.createElement)( + _router.Router, + { + basepath: __PATH_PREFIX__, + }, + (0, _react.createElement)(RouteHandler, { + path: `/*`, + }) + ) // Let site, plugins wrap the site e.g. for Redux. + +const WrappedRoot = (0, _apiRunnerBrowser.apiRunner)( + `wrapRootElement`, + { + element: _react.default.createElement(Root, null), + }, + _react.default.createElement(Root, null), + ({ result, plugin }) => { + return { + element: result, + } + } +).pop() + +var _default = () => WrappedRoot + +exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/socketIo.js b/packages/gatsby-theme/.cache/commonjs/socketIo.js new file mode 100644 index 0000000..800c766 --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/socketIo.js @@ -0,0 +1,117 @@ +'use strict' + +exports.__esModule = true +exports.default = socketIo +exports.getPageData = getPageData +exports.registerPath = registerPath +exports.unregisterPath = unregisterPath +exports.getIsInitialized = exports.getPageQueryData = exports.getStaticQueryData = void 0 + +var _errorOverlayHandler = require('./error-overlay-handler') + +let socket = null +let staticQueryData = {} +let pageQueryData = {} +let isInitialized = false + +const getStaticQueryData = () => staticQueryData + +exports.getStaticQueryData = getStaticQueryData + +const getPageQueryData = () => pageQueryData + +exports.getPageQueryData = getPageQueryData + +const getIsInitialized = () => isInitialized + +exports.getIsInitialized = getIsInitialized + +function socketIo() { + if (process.env.NODE_ENV !== `production`) { + if (!socket) { + // Try to initialize web socket if we didn't do it already + try { + // eslint-disable-next-line no-undef + socket = io() + + const didDataChange = (msg, queryData) => + !(msg.payload.id in queryData) || + JSON.stringify(msg.payload.result) !== + JSON.stringify(queryData[msg.payload.id]) + + socket.on(`message`, msg => { + if (msg.type === `staticQueryResult`) { + if (didDataChange(msg, staticQueryData)) { + staticQueryData = Object.assign({}, staticQueryData, { + [msg.payload.id]: msg.payload.result, + }) + } + } else if (msg.type === `pageQueryResult`) { + if (didDataChange(msg, pageQueryData)) { + pageQueryData = Object.assign({}, pageQueryData, { + [msg.payload.id]: msg.payload.result, + }) + } + } else if (msg.type === `overlayError`) { + if (msg.payload.message) { + ;(0, _errorOverlayHandler.reportError)( + msg.payload.id, + msg.payload.message + ) + } else { + ;(0, _errorOverlayHandler.clearError)(msg.payload.id) + } + } + + if (msg.type && msg.payload) { + ___emitter.emit(msg.type, msg.payload) + } + }) + } catch (err) { + console.error(`Could not connect to socket.io on dev server.`) + } + } + + return socket + } else { + return null + } +} + +const inFlightGetPageDataPromiseCache = {} + +function getPageData(pathname) { + if (inFlightGetPageDataPromiseCache[pathname]) { + return inFlightGetPageDataPromiseCache[pathname] + } else { + inFlightGetPageDataPromiseCache[pathname] = new Promise(resolve => { + if (pageQueryData[pathname]) { + delete inFlightGetPageDataPromiseCache[pathname] + resolve(pageQueryData[pathname]) + } else { + const onPageDataCallback = msg => { + if (msg.type === `pageQueryResult` && msg.payload.id === pathname) { + socket.off(`message`, onPageDataCallback) + delete inFlightGetPageDataPromiseCache[pathname] + resolve(pageQueryData[pathname]) + } + } + + socket.on(`message`, onPageDataCallback) + socket.emit(`getDataForPath`, pathname) + } + }) + } + + return inFlightGetPageDataPromiseCache[pathname] +} // Tell websocket-manager.js the new path we're on. +// This will help the backend prioritize queries for this +// path. + +function registerPath(path) { + socket.emit(`registerPath`, path) +} // Unregister the former path + +function unregisterPath(path) { + socket.emit(`unregisterPath`, path) +} diff --git a/packages/gatsby-theme/.cache/commonjs/static-entry.js b/packages/gatsby-theme/.cache/commonjs/static-entry.js new file mode 100644 index 0000000..3878bdd --- /dev/null +++ b/packages/gatsby-theme/.cache/commonjs/static-entry.js @@ -0,0 +1,448 @@ +'use strict' + +var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') + +exports.__esModule = true +exports.default = void 0 + +var _extends2 = _interopRequireDefault( + require('@babel/runtime/helpers/extends') +) + +const React = require(`react`) + +const fs = require(`fs`) + +const _require = require(`path`), + join = _require.join + +const _require2 = require(`react-dom/server`), + renderToString = _require2.renderToString, + renderToStaticMarkup = _require2.renderToStaticMarkup + +const _require3 = require(`@reach/router`), + ServerLocation = _require3.ServerLocation, + Router = _require3.Router, + isRedirect = _require3.isRedirect + +const _require4 = require(`lodash`), + get = _require4.get, + merge = _require4.merge, + isObject = _require4.isObject, + flatten = _require4.flatten, + uniqBy = _require4.uniqBy + +const apiRunner = require(`./api-runner-ssr`) + +const syncRequires = require(`./sync-requires`) + +const _require5 = require(`./data.json`), + dataPaths = _require5.dataPaths, + pages = _require5.pages + +const _require6 = require(`gatsby/package.json`), + gatsbyVersion = _require6.version // Speed up looking up pages. + +const pagesObjectMap = new Map() +pages.forEach(p => pagesObjectMap.set(p.path, p)) +const stats = JSON.parse( + fs.readFileSync(`${process.cwd()}/public/webpack.stats.json`, `utf-8`) +) +const chunkMapping = JSON.parse( + fs.readFileSync(`${process.cwd()}/public/chunk-map.json`, `utf-8`) +) // const testRequireError = require("./test-require-error") +// For some extremely mysterious reason, webpack adds the above module *after* +// this module so that when this code runs, testRequireError is undefined. +// So in the meantime, we'll just inline it. + +const testRequireError = (moduleName, err) => { + const regex = new RegExp(`Error: Cannot find module\\s.${moduleName}`) + const firstLine = err.toString().split(`\n`)[0] + return regex.test(firstLine) +} + +let Html + +try { + Html = require(`../src/html`) +} catch (err) { + if (testRequireError(`../src/html`, err)) { + Html = require(`./default-html`) + } else { + throw err + } +} + +Html = Html && Html.__esModule ? Html.default : Html + +const getPage = path => pagesObjectMap.get(path) + +const createElement = React.createElement + +const sanitizeComponents = components => { + if (Array.isArray(components)) { + // remove falsy items + return components.filter(val => (Array.isArray(val) ? val.length > 0 : val)) + } else { + // we also accept single components, so we need to handle this case as well + return components ? [components] : [] + } +} + +var _default = (pagePath, callback) => { + let bodyHtml = `` + let headComponents = [ + React.createElement('meta', { + name: 'generator', + content: `Gatsby ${gatsbyVersion}`, + key: `generator-${gatsbyVersion}`, + }), + ] + let htmlAttributes = {} + let bodyAttributes = {} + let preBodyComponents = [] + let postBodyComponents = [] + let bodyProps = {} + + const replaceBodyHTMLString = body => { + bodyHtml = body + } + + const setHeadComponents = components => { + headComponents = headComponents.concat(sanitizeComponents(components)) + } + + const setHtmlAttributes = attributes => { + htmlAttributes = merge(htmlAttributes, attributes) + } + + const setBodyAttributes = attributes => { + bodyAttributes = merge(bodyAttributes, attributes) + } + + const setPreBodyComponents = components => { + preBodyComponents = preBodyComponents.concat(sanitizeComponents(components)) + } + + const setPostBodyComponents = components => { + postBodyComponents = postBodyComponents.concat( + sanitizeComponents(components) + ) + } + + const setBodyProps = props => { + bodyProps = merge({}, bodyProps, props) + } + + const getHeadComponents = () => headComponents + + const replaceHeadComponents = components => { + headComponents = sanitizeComponents(components) + } + + const getPreBodyComponents = () => preBodyComponents + + const replacePreBodyComponents = components => { + preBodyComponents = sanitizeComponents(components) + } + + const getPostBodyComponents = () => postBodyComponents + + const replacePostBodyComponents = components => { + postBodyComponents = sanitizeComponents(components) + } + + const page = getPage(pagePath) + let dataAndContext = {} + + if (page.jsonName in dataPaths) { + const pathToJsonData = join( + process.cwd(), + `/public/static/d`, + `${dataPaths[page.jsonName]}.json` + ) + + try { + dataAndContext = JSON.parse(fs.readFileSync(pathToJsonData)) + } catch (e) { + console.log(`error`, pathToJsonData, e) + process.exit() + } + } + + class RouteHandler extends React.Component { + render() { + const props = Object.assign({}, this.props, dataAndContext, { + pathContext: dataAndContext.pageContext, + }) + const pageElement = createElement( + syncRequires.components[page.componentChunkName], + props + ) + const wrappedPage = apiRunner( + `wrapPageElement`, + { + element: pageElement, + props, + }, + pageElement, + ({ result }) => { + return { + element: result, + props, + } + } + ).pop() + return wrappedPage + } + } + + const routerElement = createElement( + ServerLocation, + { + url: `${__PATH_PREFIX__}${pagePath}`, + }, + createElement( + Router, + { + baseuri: `${__PATH_PREFIX__}`, + }, + createElement(RouteHandler, { + path: `/*`, + }) + ) + ) + const bodyComponent = apiRunner( + `wrapRootElement`, + { + element: routerElement, + pathname: pagePath, + }, + routerElement, + ({ result }) => { + return { + element: result, + pathname: pagePath, + } + } + ).pop() // Let the site or plugin render the page component. + + apiRunner(`replaceRenderer`, { + bodyComponent, + replaceBodyHTMLString, + setHeadComponents, + setHtmlAttributes, + setBodyAttributes, + setPreBodyComponents, + setPostBodyComponents, + setBodyProps, + pathname: pagePath, + pathPrefix: __PATH_PREFIX__, + }) // If no one stepped up, we'll handle it. + + if (!bodyHtml) { + try { + bodyHtml = renderToString(bodyComponent) + } catch (e) { + // ignore @reach/router redirect errors + if (!isRedirect(e)) throw e + } + } // Create paths to scripts + + let scriptsAndStyles = flatten( + [`app`, page.componentChunkName].map(s => { + const fetchKey = `assetsByChunkName[${s}]` + let chunks = get(stats, fetchKey) + let namedChunkGroups = get(stats, `namedChunkGroups`) + + if (!chunks) { + return null + } + + chunks = chunks.map(chunk => { + if (chunk === `/`) { + return null + } + + return { + rel: `preload`, + name: chunk, + } + }) + namedChunkGroups[s].assets.forEach(asset => + chunks.push({ + rel: `preload`, + name: asset, + }) + ) + const childAssets = namedChunkGroups[s].childAssets + + for (const rel in childAssets) { + chunks = merge( + chunks, + childAssets[rel].map(chunk => { + return { + rel, + name: chunk, + } + }) + ) + } + + return chunks + }) + ) + .filter(s => isObject(s)) + .sort((s1, s2) => (s1.rel == `preload` ? -1 : 1)) // given priority to preload + + scriptsAndStyles = uniqBy(scriptsAndStyles, item => item.name) + const scripts = scriptsAndStyles.filter( + script => script.name && script.name.endsWith(`.js`) + ) + const styles = scriptsAndStyles.filter( + style => style.name && style.name.endsWith(`.css`) + ) + apiRunner(`onRenderBody`, { + setHeadComponents, + setHtmlAttributes, + setBodyAttributes, + setPreBodyComponents, + setPostBodyComponents, + setBodyProps, + pathname: pagePath, + bodyHtml, + scripts, + styles, + pathPrefix: __PATH_PREFIX__, + }) + scripts + .slice(0) + .reverse() + .forEach(script => { + // Add preload/prefetch s for scripts. + headComponents.push( + React.createElement('link', { + as: 'script', + rel: script.rel, + key: script.name, + href: `${__PATH_PREFIX__}/${script.name}`, + }) + ) + }) + + if (page.jsonName in dataPaths) { + const dataPath = `${__PATH_PREFIX__}/static/d/${ + dataPaths[page.jsonName] + }.json` + headComponents.push( + React.createElement('link', { + as: 'fetch', + rel: 'preload', + key: dataPath, + href: dataPath, + crossOrigin: 'use-credentials', + }) + ) + } + + styles + .slice(0) + .reverse() + .forEach(style => { + // Add s for styles that should be prefetched + // otherwise, inline as a
"`; - -exports[`develop-static-entry onPreRenderHTML can be used to replace postBodyComponents 1`] = `"
div3
div2
div1
"`; - -exports[`develop-static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`; - -exports[`static-entry onPreRenderHTML can be used to replace headComponents 1`] = `"
"`; - -exports[`static-entry onPreRenderHTML can be used to replace postBodyComponents 1`] = `"
div3
div2
div1
"`; - -exports[`static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`; diff --git a/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js b/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js deleted file mode 100644 index f082280..0000000 --- a/packages/gatsby-theme/.cache/__tests__/error-overlay-handler.js +++ /dev/null @@ -1,59 +0,0 @@ -import '@babel/polyfill' -const { - reportError, - clearError, - errorMap, -} = require(`../error-overlay-handler`) - -import * as ErrorOverlay from 'react-error-overlay' - -jest.mock(`react-error-overlay`, () => { - return { - reportBuildError: jest.fn(), - dismissBuildError: jest.fn(), - startReportingRuntimeErrors: jest.fn(), - setEditorHandler: jest.fn(), - } -}) - -beforeEach(() => { - ErrorOverlay.reportBuildError.mockClear() - ErrorOverlay.dismissBuildError.mockClear() -}) - -describe(`errorOverlayHandler`, () => { - describe(`clearError()`, () => { - beforeEach(() => { - reportError(`foo`, `error`) - reportError(`bar`, `error`) - }) - afterAll(() => { - clearError(`foo`) - clearError(`bar`) - }) - it(`should clear specific error type`, () => { - expect(Object.keys(errorMap)).toHaveLength(2) - clearError(`foo`) - expect(Object.keys(errorMap)).toHaveLength(1) - expect(ErrorOverlay.dismissBuildError).not.toHaveBeenCalled() - }) - - it(`should call ErrorOverlay to dismiss build errors`, () => { - clearError(`foo`) - clearError(`bar`) - expect(ErrorOverlay.dismissBuildError).toHaveBeenCalled() - }) - }) - describe(`reportErrorOverlay()`, () => { - it(`should not add error if it's empty and not call ErrorOverlay`, () => { - reportError(`foo`, null) - expect(Object.keys(errorMap)).toHaveLength(0) - expect(ErrorOverlay.reportBuildError).not.toHaveBeenCalled() - }) - it(`should add error if it has a truthy value and call ErrorOverlay`, () => { - reportError(`foo`, `bar`) - expect(Object.keys(errorMap)).toHaveLength(1) - expect(ErrorOverlay.reportBuildError).toHaveBeenCalled() - }) - }) -}) diff --git a/packages/gatsby-theme/.cache/__tests__/find-page.js b/packages/gatsby-theme/.cache/__tests__/find-page.js deleted file mode 100644 index c998b8e..0000000 --- a/packages/gatsby-theme/.cache/__tests__/find-page.js +++ /dev/null @@ -1,67 +0,0 @@ -const pageFinderFactory = require(`../find-page`).default - -let findPage - -describe(`find-page`, () => { - beforeEach(() => { - const newPages = [ - { - path: `/about/`, - componentChunkName: `page-component---src-pages-test-js`, - jsonName: `about.json`, - }, - { - path: `/about/me/`, - componentChunkName: `page-component---src-pages-test-js`, - jsonName: `about-me.json`, - }, - { - path: `/about/the best/`, - componentChunkName: `page-component---src-pages-test-js`, - jsonName: `the-best.json`, - }, - { - path: `/app/`, - matchPath: `/app/*`, - componentChunkName: `page-component---src-pages-app-js`, - jsonName: `app.json`, - }, - ] - findPage = pageFinderFactory(newPages) - }) - - it(`can find a page`, () => { - expect(findPage(`/about/`).path).toBe(`/about/`) - expect(findPage(`/about/me/`).path).toBe(`/about/me/`) - }) - - it(`can find a page with space in its path`, () => { - expect(findPage(`/about/the best/`).path).toBe(`/about/the best/`) - expect(findPage(`/about/the%20best/`).path).toBe(`/about/the best/`) - }) - - it(`can find a client only path`, () => { - expect(findPage(`/about/super-duper/`)).toBeUndefined() - expect(findPage(`/app/client/only/path`).path).toBe(`/app/`) - }) - - it(`can find links with hashes`, () => { - expect(findPage(`/about/me/#hashtagawesome`).path).toBe(`/about/me/`) - }) - - it(`can find links with search query`, () => { - expect(findPage(`/about/me/?query=awesome`).path).toBe(`/about/me/`) - }) - - it(`handles finding prefixed links`, () => { - const newPages = [ - { - path: `/about/`, - componentChunkName: `page-component---src-pages-test-js`, - jsonName: `about.json`, - }, - ] - const findPage2 = pageFinderFactory(newPages, `/my-test-prefix`) - expect(findPage2(`/my-test-prefix/about/`).path).toBe(`/about/`) - }) -}) diff --git a/packages/gatsby-theme/.cache/__tests__/minimal-config.js b/packages/gatsby-theme/.cache/__tests__/minimal-config.js deleted file mode 100644 index ef2c4c9..0000000 --- a/packages/gatsby-theme/.cache/__tests__/minimal-config.js +++ /dev/null @@ -1,32 +0,0 @@ -const path = require(`path`) -const child = require(`child_process`) - -it(`Builds cache-dir with minimal config`, done => { - const args = [ - require.resolve(`@babel/cli/bin/babel.js`), - path.join(__dirname, `..`), - `--config-file`, - path.join(__dirname, `.babelrc`), - `--ignore`, - `**/__tests__`, - ] - - const spawn = child.spawn(process.execPath, args) - - let stderr = `` - let stdout = `` - - spawn.stderr.on(`data`, function(chunk) { - stderr += chunk - }) - - spawn.stdout.on(`data`, function(chunk) { - stdout += chunk - }) - - spawn.on(`close`, function() { - expect(stderr).toEqual(``) - expect(stdout).not.toEqual(``) - done() - }) -}, 30000) diff --git a/packages/gatsby-theme/.cache/__tests__/static-entry.js b/packages/gatsby-theme/.cache/__tests__/static-entry.js deleted file mode 100644 index 1dbf93f..0000000 --- a/packages/gatsby-theme/.cache/__tests__/static-entry.js +++ /dev/null @@ -1,274 +0,0 @@ -import React from 'react' -import fs from 'fs' - -import DevelopStaticEntry from '../develop-static-entry' - -jest.mock(`fs`, () => { - const fs = jest.requireActual(`fs`) - return { - ...fs, - readFileSync: jest.fn(), - } -}) -jest.mock(`gatsby/package.json`, () => { - return { - version: `2.0.0`, - } -}) - -jest.mock( - `../sync-requires`, - () => { - return { - components: { - 'page-component---src-pages-test-js': () => null, - }, - } - }, - { - virtual: true, - } -) - -jest.mock( - `../data.json`, - () => { - return { - dataPaths: [ - { - [`about.json`]: `/400/about`, - }, - ], - pages: [ - { - path: `/about/`, - componentChunkName: `page-component---src-pages-test-js`, - jsonName: `about.json`, - }, - ], - } - }, - { - virtual: true, - } -) - -const MOCK_FILE_INFO = { - [`${process.cwd()}/public/webpack.stats.json`]: `{}`, - [`${process.cwd()}/public/chunk-map.json`]: `{}`, -} - -let StaticEntry -beforeEach(() => { - fs.readFileSync.mockImplementation(file => MOCK_FILE_INFO[file]) - StaticEntry = require(`../static-entry`).default -}) - -const reverseHeadersPlugin = { - plugin: { - onPreRenderHTML: ({ getHeadComponents, replaceHeadComponents }) => { - const headComponents = getHeadComponents() - headComponents.reverse() - replaceHeadComponents(headComponents) - }, - }, -} - -const injectValuePlugin = (hookName, methodName, value) => { - return { - plugin: { - [hookName]: staticEntry => { - const method = staticEntry[methodName] - method(value) - }, - }, - } -} - -const checkSanitized = components => { - expect(components.includes(null)).toBeFalsy() - expect( - components.find(val => Array.isArray(val) && val.length === 0) - ).toBeFalsy() -} - -const checkNonEmptyHeadersPlugin = { - plugin: { - onPreRenderHTML: ({ - getHeadComponents, - getPreBodyComponents, - getPostBodyComponents, - }) => { - const headComponents = getHeadComponents() - const preBodyComponents = getPreBodyComponents() - const postBodyComponents = getPostBodyComponents() - checkSanitized(headComponents) - checkSanitized(preBodyComponents) - checkSanitized(postBodyComponents) - }, - }, -} - -const fakeStylesPlugin = { - plugin: { - onRenderBody: ({ setHeadComponents }) => - setHeadComponents([ - , - , - , - ]), - }, -} - -const reverseBodyComponentsPluginFactory = type => { - return { - plugin: { - onPreRenderHTML: props => { - const components = props[`get${type}BodyComponents`]() - components.reverse() - props[`replace${type}BodyComponents`](components) - }, - }, - } -} - -const fakeComponentsPluginFactory = type => { - return { - plugin: { - onRenderBody: props => { - props[`set${type}BodyComponents`]([ -
div1
, -
div2
, -
div3
, - ]) - }, - }, - } -} - -describe(`develop-static-entry`, () => { - test(`onPreRenderHTML can be used to replace headComponents`, done => { - global.plugins = [fakeStylesPlugin, reverseHeadersPlugin] - - DevelopStaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) - - test(`onPreRenderHTML can be used to replace postBodyComponents`, done => { - global.plugins = [ - fakeComponentsPluginFactory(`Post`), - reverseBodyComponentsPluginFactory(`Post`), - ] - - DevelopStaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) - - test(`onPreRenderHTML can be used to replace preBodyComponents`, done => { - global.plugins = [ - fakeComponentsPluginFactory(`Pre`), - reverseBodyComponentsPluginFactory(`Pre`), - ] - - DevelopStaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) -}) - -describe(`static-entry sanity checks`, () => { - beforeEach(() => { - global.__PATH_PREFIX__ = `` - }) - - const methodsToCheck = [ - `replaceHeadComponents`, - `replacePreBodyComponents`, - `replacePostBodyComponents`, - ] - - methodsToCheck.forEach(methodName => { - test(`${methodName} can filter out null value`, done => { - const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, null) - global.plugins = [plugin, checkNonEmptyHeadersPlugin] - - StaticEntry(`/about/`, (_, html) => { - done() - }) - }) - - test(`${methodName} can filter out null values`, done => { - const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, [ - null, - null, - ]) - global.plugins = [plugin, checkNonEmptyHeadersPlugin] - - StaticEntry(`/about/`, (_, html) => { - done() - }) - }) - - test(`${methodName} can filter out empty array`, done => { - const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, []) - global.plugins = [plugin, checkNonEmptyHeadersPlugin] - - StaticEntry(`/about/`, (_, html) => { - done() - }) - }) - - test(`${methodName} can filter out empty arrays`, done => { - const plugin = injectValuePlugin(`onPreRenderHTML`, methodName, [[], []]) - global.plugins = [plugin, checkNonEmptyHeadersPlugin] - - StaticEntry(`/about/`, (_, html) => { - done() - }) - }) - }) -}) - -describe(`static-entry`, () => { - beforeEach(() => { - global.__PATH_PREFIX__ = `` - }) - - test(`onPreRenderHTML can be used to replace headComponents`, done => { - global.plugins = [fakeStylesPlugin, reverseHeadersPlugin] - - StaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) - - test(`onPreRenderHTML can be used to replace postBodyComponents`, done => { - global.plugins = [ - fakeComponentsPluginFactory(`Post`), - reverseBodyComponentsPluginFactory(`Post`), - ] - - StaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) - - test(`onPreRenderHTML can be used to replace preBodyComponents`, done => { - global.plugins = [ - fakeComponentsPluginFactory(`Pre`), - reverseBodyComponentsPluginFactory(`Pre`), - ] - - StaticEntry(`/about/`, (_, html) => { - expect(html).toMatchSnapshot() - done() - }) - }) -}) diff --git a/packages/gatsby-theme/.cache/__tests__/strip-prefix.js b/packages/gatsby-theme/.cache/__tests__/strip-prefix.js deleted file mode 100644 index 78fc19b..0000000 --- a/packages/gatsby-theme/.cache/__tests__/strip-prefix.js +++ /dev/null @@ -1,23 +0,0 @@ -const stripPrefix = require(`../strip-prefix`).default - -describe(`strip-prefix`, () => { - it(`strips a prefix`, () => { - expect(stripPrefix(`/foo/bar/`, `/foo`)).toBe(`/bar/`) - }) - - it(`strips first instance only`, () => { - expect(stripPrefix(`/foo/foo/bar/`, `/foo`)).toBe(`/foo/bar/`) - }) - - it(`ignores prefix appearing elsewhere in the string`, () => { - expect(stripPrefix(`/foo/bar/`, `bar`)).toBe(`/foo/bar/`) - }) - - it(`ignores a non-existent prefix`, () => { - expect(stripPrefix(`/bar`, `/foo`)).toBe(`/bar`) - }) - - it(`returns input str if no prefix is provided`, () => { - expect(stripPrefix(`/bar`)).toBe(`/bar`) - }) -}) diff --git a/packages/gatsby-theme/.cache/api-runner-browser-plugins.js b/packages/gatsby-theme/.cache/api-runner-browser-plugins.js deleted file mode 100644 index 19a4308..0000000 --- a/packages/gatsby-theme/.cache/api-runner-browser-plugins.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = [ - { - plugin: require('/Users/jxnblk/repos/mdx-deck/node_modules/gatsby-mdx/gatsby-browser.js'), - options: { plugins: [], extensions: ['.mdx', '.md'] }, - }, -] diff --git a/packages/gatsby-theme/.cache/api-runner-browser.js b/packages/gatsby-theme/.cache/api-runner-browser.js deleted file mode 100644 index 0a4ff8b..0000000 --- a/packages/gatsby-theme/.cache/api-runner-browser.js +++ /dev/null @@ -1,55 +0,0 @@ -const plugins = require(`./api-runner-browser-plugins`) -const { - getResourcesForPathname, - getResourcesForPathnameSync, - getResourceURLsForPathname, -} = require(`./loader`).publicLoader - -exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => { - // Hooks for gatsby-cypress's API handler - if (process.env.CYPRESS_SUPPORT) { - if (window.___apiHandler) { - window.___apiHandler(api) - } else if (window.___resolvedAPIs) { - window.___resolvedAPIs.push(api) - } else { - window.___resolvedAPIs = [api] - } - } - - let results = plugins.map(plugin => { - if (!plugin.plugin[api]) { - return undefined - } - - args.getResourcesForPathnameSync = getResourcesForPathnameSync - args.getResourcesForPathname = getResourcesForPathname - args.getResourceURLsForPathname = getResourceURLsForPathname - - const result = plugin.plugin[api](args, plugin.options) - if (result && argTransform) { - args = argTransform({ args, result, plugin }) - } - return result - }) - - // Filter out undefined results. - results = results.filter(result => typeof result !== `undefined`) - - if (results.length > 0) { - return results - } else if (defaultReturn) { - return [defaultReturn] - } else { - return [] - } -} - -exports.apiRunnerAsync = (api, args, defaultReturn) => - plugins.reduce( - (previous, next) => - next.plugin[api] - ? previous.then(() => next.plugin[api](args, next.options)) - : previous, - Promise.resolve() - ) diff --git a/packages/gatsby-theme/.cache/api-runner-ssr.js b/packages/gatsby-theme/.cache/api-runner-ssr.js deleted file mode 100644 index cfbcbf1..0000000 --- a/packages/gatsby-theme/.cache/api-runner-ssr.js +++ /dev/null @@ -1,48 +0,0 @@ -var plugins = [ - { - plugin: require('/Users/jxnblk/repos/mdx-deck/node_modules/gatsby-mdx/gatsby-ssr'), - options: { plugins: [], extensions: ['.mdx', '.md'] }, - }, -] -// During bootstrap, we write requires at top of this file which looks like: -// var plugins = [ -// { -// plugin: require("/path/to/plugin1/gatsby-ssr.js"), -// options: { ... }, -// }, -// { -// plugin: require("/path/to/plugin2/gatsby-ssr.js"), -// options: { ... }, -// }, -// ] - -const apis = require(`./api-ssr-docs`) - -// Run the specified API in any plugins that have implemented it -module.exports = (api, args, defaultReturn, argTransform) => { - if (!apis[api]) { - console.log(`This API doesn't exist`, api) - } - - // Run each plugin in series. - // eslint-disable-next-line no-undef - let results = plugins.map(plugin => { - if (!plugin.plugin[api]) { - return undefined - } - const result = plugin.plugin[api](args, plugin.options) - if (result && argTransform) { - args = argTransform({ args, result }) - } - return result - }) - - // Filter out undefined results. - results = results.filter(result => typeof result !== `undefined`) - - if (results.length > 0) { - return results - } else { - return [defaultReturn] - } -} diff --git a/packages/gatsby-theme/.cache/api-ssr-docs.js b/packages/gatsby-theme/.cache/api-ssr-docs.js deleted file mode 100644 index b2897dd..0000000 --- a/packages/gatsby-theme/.cache/api-ssr-docs.js +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Replace the default server renderer. This is useful for integration with - * Redux, css-in-js libraries, etc. that need custom setups for server - * rendering. - * @param {Object} $0 - * @param {function} $0.replaceBodyHTMLString Call this with the HTML string - * you render. **WARNING** if multiple plugins implement this API it's the - * last plugin that "wins". TODO implement an automated warning against this. - * @param {function} $0.setHeadComponents Takes an array of components as its - * first argument which are added to the `headComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setHtmlAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setBodyAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setPreBodyComponents Takes an array of components as its - * first argument which are added to the `preBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setPostBodyComponents Takes an array of components as its - * first argument which are added to the `postBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setBodyProps Takes an object of data which - * is merged with other body props and passed to `html.js` as `bodyProps`. - * @param {Object} pluginOptions - * @example - * // From gatsby-plugin-glamor - * const { renderToString } = require("react-dom/server") - * const inline = require("glamor-inline") - * - * exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { - * const bodyHTML = renderToString(bodyComponent) - * const inlinedHTML = inline(bodyHTML) - * - * replaceBodyHTMLString(inlinedHTML) - * } - */ -exports.replaceRenderer = true - -/** - * Called after every page Gatsby server renders while building HTML so you can - * set head and body components to be rendered in your `html.js`. - * - * Gatsby does a two-pass render for HTML. It loops through your pages first - * rendering only the body and then takes the result body HTML string and - * passes it as the `body` prop to your `html.js` to complete the render. - * - * It's often handy to be able to send custom components to your `html.js`. - * For example, it's a very common pattern for React.js libraries that - * support server rendering to pull out data generated during the render to - * add to your HTML. - * - * Using this API over [`replaceRenderer`](#replaceRenderer) is preferable as - * multiple plugins can implement this API where only one plugin can take - * over server rendering. However, if your plugin requires taking over server - * rendering then that's the one to - * use - * @param {Object} $0 - * @param {string} $0.pathname The pathname of the page currently being rendered. - * @param {function} $0.setHeadComponents Takes an array of components as its - * first argument which are added to the `headComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setHtmlAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setBodyAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setPreBodyComponents Takes an array of components as its - * first argument which are added to the `preBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setPostBodyComponents Takes an array of components as its - * first argument which are added to the `postBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setBodyProps Takes an object of data which - * is merged with other body props and passed to `html.js` as `bodyProps`. - * @param {Object} pluginOptions - * @example - * const { Helmet } = require("react-helmet") - * - * exports.onRenderBody = ( - * { setHeadComponents, setHtmlAttributes, setBodyAttributes }, - * pluginOptions - * ) => { - * const helmet = Helmet.renderStatic() - * setHtmlAttributes(helmet.htmlAttributes.toComponent()) - * setBodyAttributes(helmet.bodyAttributes.toComponent()) - * setHeadComponents([ - * helmet.title.toComponent(), - * helmet.link.toComponent(), - * helmet.meta.toComponent(), - * helmet.noscript.toComponent(), - * helmet.script.toComponent(), - * helmet.style.toComponent(), - * ]) - * } - */ -exports.onRenderBody = true - -/** - * Called after every page Gatsby server renders while building HTML so you can - * replace head components to be rendered in your `html.js`. This is useful if - * you need to reorder scripts or styles added by other plugins. - * @param {Object} $0 - * @param {Array} $0.getHeadComponents Returns the current `headComponents` array. - * @param {function} $0.replaceHeadComponents Takes an array of components as its - * first argument which replace the `headComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Array} $0.getPreBodyComponents Returns the current `preBodyComponents` array. - * @param {function} $0.replacePreBodyComponents Takes an array of components as its - * first argument which replace the `preBodyComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Array} $0.getPostBodyComponents Returns the current `postBodyComponents` array. - * @param {function} $0.replacePostBodyComponents Takes an array of components as its - * first argument which replace the `postBodyComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Object} pluginOptions - * @example - * // Move Typography.js styles to the top of the head section so they're loaded first. - * exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => { - * const headComponents = getHeadComponents() - * headComponents.sort((x, y) => { - * if (x.key === 'TypographyStyle') { - * return -1 - * } else if (y.key === 'TypographyStyle') { - * return 1 - * } - * return 0 - * }) - * replaceHeadComponents(headComponents) - * } - */ -exports.onPreRenderHTML = true - -/** - * Allow a plugin to wrap the page element. - * - * This is useful for setting wrapper component around pages that won't get - * unmounted on page change. For setting Provider components use [wrapRootElement](#wrapRootElement). - * - * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapPageElement) - * @param {object} $0 - * @param {ReactNode} $0.element The "Page" React Element built by Gatsby. - * @param {object} $0.props Props object used by page. - * @example - * import React from "react" - * import Layout from "./src/components/layout" - * - * export const wrapPageElement = ({ element, props }) => { - * // props provide same data to Layout as Page element will get - * // including location, data, etc - you don't need to pass it - * return {element} - * } - */ -exports.wrapPageElement = true - -/** - * Allow a plugin to wrap the root element. - * - * This is useful to setup any Providers component that will wrap your application. - * For setting persistent UI elements around pages use [wrapPageElement](#wrapPageElement). - * - * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapRootElement) - * @param {object} $0 - * @param {ReactNode} $0.element The "Root" React Element built by Gatsby. - * @example - * import React from "react" - * import { Provider } from "react-redux" - * - * import createStore from "./src/state/createStore" - * const store = createStore() - * - * export const wrapRootElement = ({ element }) => { - * return ( - * - * {element} - * - * ) - * } - */ -exports.wrapRootElement = true diff --git a/packages/gatsby-theme/.cache/app.js b/packages/gatsby-theme/.cache/app.js deleted file mode 100644 index d161b75..0000000 --- a/packages/gatsby-theme/.cache/app.js +++ /dev/null @@ -1,69 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import domReady from '@mikaelkristiansson/domready' - -import socketIo from './socketIo' -import emitter from './emitter' -import { apiRunner, apiRunnerAsync } from './api-runner-browser' -import loader, { setApiRunnerForLoader, postInitialRenderWork } from './loader' -import syncRequires from './sync-requires' -import pages from './pages.json' - -window.___emitter = emitter -setApiRunnerForLoader(apiRunner) - -// Let the site/plugins run code very early. -apiRunnerAsync(`onClientEntry`).then(() => { - // Hook up the client to socket.io on server - const socket = socketIo() - if (socket) { - socket.on(`reload`, () => { - window.location.reload() - }) - } - - /** - * Service Workers are persistent by nature. They stick around, - * serving a cached version of the site if they aren't removed. - * This is especially frustrating when you need to test the - * production build on your local machine. - * - * Let's unregister the service workers in development, and tidy up a few errors. - */ - if (supportsServiceWorkers(location, navigator)) { - navigator.serviceWorker.getRegistrations().then(registrations => { - for (let registration of registrations) { - registration.unregister() - } - }) - } - - const rootElement = document.getElementById(`___gatsby`) - - const renderer = apiRunner( - `replaceHydrateFunction`, - undefined, - ReactDOM.render - )[0] - - loader.addPagesArray(pages) - loader.addDevRequires(syncRequires) - - loader.getResourcesForPathname(window.location.pathname).then(() => { - const preferDefault = m => (m && m.default) || m - let Root = preferDefault(require(`./root`)) - domReady(() => { - renderer(, rootElement, () => { - postInitialRenderWork() - apiRunner(`onInitialClientRender`) - }) - }) - }) -}) - -function supportsServiceWorkers(location, navigator) { - if (location.hostname === `localhost` || location.protocol === `https:`) { - return `serviceWorker` in navigator - } - return false -} diff --git a/packages/gatsby-theme/.cache/async-requires.js b/packages/gatsby-theme/.cache/async-requires.js deleted file mode 100644 index 2786308..0000000 --- a/packages/gatsby-theme/.cache/async-requires.js +++ /dev/null @@ -1,16 +0,0 @@ -// prefer default export if available -const preferDefault = m => (m && m.default) || m - -exports.components = { - 'component---src-decks-js': () => - import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/decks.js' /* webpackChunkName: "component---src-decks-js" */), - 'component---src-template-js': () => - import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/template.js' /* webpackChunkName: "component---src-template-js" */), - 'component---cache-dev-404-page-js': () => - import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/.cache/dev-404-page.js' /* webpackChunkName: "component---cache-dev-404-page-js" */), - 'component---src-pages-index-mdx': () => - import('/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/src/pages/index.mdx' /* webpackChunkName: "component---src-pages-index-mdx" */), -} - -exports.data = () => - import(/* webpackChunkName: "pages-manifest" */ '/Users/jxnblk/repos/mdx-deck/packages/gatsby-theme/.cache/data.json') diff --git a/packages/gatsby-theme/.cache/babelState.json b/packages/gatsby-theme/.cache/babelState.json deleted file mode 100644 index 8c8cbaf..0000000 --- a/packages/gatsby-theme/.cache/babelState.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "stages": { - "develop": { - "plugins": [ - { - "name": "@babel/plugin-proposal-object-rest-spread", - "options": {} - } - ], - "presets": [], - "options": { - "cacheDirectory": true, - "sourceType": "unambiguous" - } - }, - "develop-html": { - "plugins": [ - { - "name": "@babel/plugin-proposal-object-rest-spread", - "options": {} - } - ], - "presets": [], - "options": { - "cacheDirectory": true, - "sourceType": "unambiguous" - } - }, - "build-html": { - "plugins": [ - { - "name": "@babel/plugin-proposal-object-rest-spread", - "options": {} - } - ], - "presets": [], - "options": { - "cacheDirectory": true, - "sourceType": "unambiguous" - } - }, - "build-javascript": { - "plugins": [ - { - "name": "@babel/plugin-proposal-object-rest-spread", - "options": {} - } - ], - "presets": [], - "options": { - "cacheDirectory": true, - "sourceType": "unambiguous" - } - } - }, - "browserslist": [">0.25%", "not dead"] -} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json deleted file mode 100644 index a8d5f08..0000000 --- a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-78682d9aeb406f36b6b09928aad04ebc.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "expireTime": 9007200809682330000, - "key": "gatsby-mdx-entire-payload-baeb8a140a332d9bf75f44c55c64cb65-", - "val": { - "mdast": { - "type": "root", - "children": [ - { - "type": "import", - "value": "import { Link } from 'gatsby'", - "position": { - "start": { "line": 1, "column": 1, "offset": 0 }, - "end": { "line": 1, "column": 30, "offset": 29 }, - "indent": [] - } - }, - { - "type": "heading", - "depth": 1, - "children": [ - { - "type": "text", - "value": "@mdx-deck/gatsby-theme", - "position": { - "start": { "line": 3, "column": 3, "offset": 33 }, - "end": { "line": 3, "column": 25, "offset": 55 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 3, "column": 1, "offset": 31 }, - "end": { "line": 3, "column": 25, "offset": 55 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "A Gatsby theme for creating presentation decks with MDX", - "position": { - "start": { "line": 5, "column": 1, "offset": 57 }, - "end": { "line": 5, "column": 56, "offset": 112 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 5, "column": 1, "offset": 57 }, - "end": { "line": 5, "column": 56, "offset": 112 }, - "indent": [] - } - }, - { - "type": "jsx", - "value": "View decks", - "position": { - "start": { "line": 7, "column": 1, "offset": 114 }, - "end": { "line": 7, "column": 36, "offset": 149 }, - "indent": [] - } - }, - { - "type": "export", - "value": "export const _frontmatter = {}", - "position": { - "start": { "line": 11, "column": 1, "offset": 153 }, - "end": { "line": 11, "column": 31, "offset": 183 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 1, "column": 1, "offset": 0 }, - "end": { "line": 11, "column": 31, "offset": 183 } - } - }, - "scopeImports": [], - "scopeIdentifiers": [], - "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\nimport { Link } from 'gatsby'\nexport const _frontmatter = {}\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n\n

{`@mdx-deck/gatsby-theme`}

\n

{`A Gatsby theme for creating presentation decks with MDX`}

\nView decks\n\n \n )\n}\nMDXContent.isMDXComponent = true" - } -} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json deleted file mode 100644 index e2ee3b7..0000000 --- a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-9b107b685825a8d9ccf2be031e4d3ae3.json +++ /dev/null @@ -1,258 +0,0 @@ -{ - "expireTime": 9007200809682327000, - "key": "gatsby-mdx-entire-payload-5769e800aec14b9252f179abd94cf8d5-", - "val": { - "mdast": { - "type": "root", - "children": [ - { - "type": "export", - "value": "export const theme = {\n colors: {\n text: 'tomato',\n background: 'black',\n }\n}", - "position": { - "start": { "line": 2, "column": 1, "offset": 1 }, - "end": { "line": 7, "column": 2, "offset": 86 }, - "indent": [1, 1, 1, 1, 1] - } - }, - { - "type": "heading", - "depth": 1, - "children": [ - { - "type": "text", - "value": "Hello", - "position": { - "start": { "line": 9, "column": 3, "offset": 90 }, - "end": { "line": 9, "column": 8, "offset": 95 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 9, "column": 1, "offset": 88 }, - "end": { "line": 9, "column": 8, "offset": 95 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 11, "column": 1, "offset": 97 }, - "end": { "line": 11, "column": 4, "offset": 100 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This is the MDX Deck Gatsby theme", - "position": { - "start": { "line": 13, "column": 1, "offset": 102 }, - "end": { "line": 13, "column": 34, "offset": 135 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 13, "column": 1, "offset": 102 }, - "end": { "line": 13, "column": 34, "offset": 135 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 15, "column": 1, "offset": 137 }, - "end": { "line": 15, "column": 4, "offset": 140 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "npm i @mdx-deck/gatsby-theme", - "position": { - "start": { "line": 17, "column": 1, "offset": 142 }, - "end": { "line": 17, "column": 31, "offset": 172 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 17, "column": 1, "offset": 142 }, - "end": { "line": 17, "column": 31, "offset": 172 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 19, "column": 1, "offset": 174 }, - "end": { "line": 19, "column": 4, "offset": 177 }, - "indent": [] - } - }, - { - "type": "code", - "lang": "js", - "meta": null, - "value": "// gatsby-config.js\nmodule.exports = {\n __experimentalThemes: [\n '@mdx-deck/gatsby-theme',\n ]\n}", - "position": { - "start": { "line": 21, "column": 1, "offset": 179 }, - "end": { "line": 28, "column": 4, "offset": 289 }, - "indent": [1, 1, 1, 1, 1, 1, 1] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 30, "column": 1, "offset": 291 }, - "end": { "line": 30, "column": 4, "offset": 294 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "mkdir src src/decks", - "position": { - "start": { "line": 32, "column": 1, "offset": 296 }, - "end": { "line": 32, "column": 22, "offset": 317 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 32, "column": 1, "offset": 296 }, - "end": { "line": 32, "column": 22, "offset": 317 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 34, "column": 1, "offset": 319 }, - "end": { "line": 34, "column": 4, "offset": 322 }, - "indent": [] - } - }, - { - "type": "list", - "ordered": true, - "start": 1, - "spread": false, - "children": [ - { - "type": "listItem", - "spread": false, - "checked": null, - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Add an MDX deck to ", - "position": { - "start": { "line": 36, "column": 4, "offset": 327 }, - "end": { "line": 36, "column": 23, "offset": 346 }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "src/decks", - "position": { - "start": { "line": 36, "column": 23, "offset": 346 }, - "end": { "line": 36, "column": 34, "offset": 357 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 36, "column": 4, "offset": 327 }, - "end": { "line": 36, "column": 34, "offset": 357 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 36, "column": 1, "offset": 324 }, - "end": { "line": 36, "column": 34, "offset": 357 }, - "indent": [] - } - }, - { - "type": "listItem", - "spread": false, - "checked": null, - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Navigate to ", - "position": { - "start": { "line": 37, "column": 4, "offset": 361 }, - "end": { "line": 37, "column": 16, "offset": 373 }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "http://localhost.com/decks", - "position": { - "start": { "line": 37, "column": 16, "offset": 373 }, - "end": { "line": 37, "column": 44, "offset": 401 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 37, "column": 4, "offset": 361 }, - "end": { "line": 37, "column": 44, "offset": 401 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 37, "column": 1, "offset": 358 }, - "end": { "line": 37, "column": 44, "offset": 401 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 36, "column": 1, "offset": 324 }, - "end": { "line": 37, "column": 44, "offset": 401 }, - "indent": [1] - } - }, - { - "type": "export", - "value": "export const _frontmatter = {}", - "position": { - "start": { "line": 41, "column": 1, "offset": 405 }, - "end": { "line": 41, "column": 31, "offset": 435 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 1, "column": 1, "offset": 0 }, - "end": { "line": 41, "column": 31, "offset": 435 } - } - }, - "scopeImports": ["import React from 'react'"], - "scopeIdentifiers": ["React"], - "body": "function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar theme = {\n colors: {\n text: 'tomato',\n background: 'black'\n }\n};\nvar _frontmatter = {};\nvar layoutProps = {\n theme: theme,\n _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n var components = _ref.components,\n props = _objectWithoutProperties(_ref, [\"components\"]);\n\n return mdx(MDXLayout, _extends({}, layoutProps, props, {\n components: components\n }), mdx(\"h1\", null, \"Hello\"), mdx(\"hr\", null), mdx(\"p\", null, \"This is the MDX Deck Gatsby theme\"), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"npm i @mdx-deck/gatsby-theme\")), mdx(\"hr\", null), mdx(\"pre\", null, mdx(\"code\", _extends({\n parentName: \"pre\"\n }, {\n \"className\": \"language-js\"\n }), \"// gatsby-config.js\\nmodule.exports = {\\n __experimentalThemes: [\\n '@mdx-deck/gatsby-theme',\\n ]\\n}\\n\")), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"mkdir src src/decks\")), mdx(\"hr\", null), mdx(\"ol\", null, mdx(\"li\", {\n parentName: \"ol\"\n }, \"Add an MDX deck to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"src/decks\")), mdx(\"li\", {\n parentName: \"ol\"\n }, \"Navigate to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"http://localhost.com/decks\"))));\n}\nMDXContent.isMDXComponent = true;", - "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\n\nexport const theme = {\n colors: {\n text: 'tomato',\n background: 'black',\n }\n}\nexport const _frontmatter = {}\nconst layoutProps = {\n theme,\n_frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n\n

{`Hello`}

\n
\n

{`This is the MDX Deck Gatsby theme`}

\n
\n

{`npm i @mdx-deck/gatsby-theme`}

\n
\n
{`// gatsby-config.js\nmodule.exports = {\n  __experimentalThemes: [\n    '@mdx-deck/gatsby-theme',\n  ]\n}\n`}
\n
\n

{`mkdir src src/decks`}

\n
\n
    \n
  1. {`Add an MDX deck to `}{`src/decks`}
  2. \n
  3. {`Navigate to `}{`http://localhost.com/decks`}
  4. \n
\n\n \n )\n}\nMDXContent.isMDXComponent = true" - } -} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json b/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json deleted file mode 100644 index 9bf352f..0000000 --- a/packages/gatsby-theme/.cache/caches/gatsby-mdx/diskstore-c15279c10aa984fadeb4921a3dbb6447.json +++ /dev/null @@ -1,249 +0,0 @@ -{ - "expireTime": 9007200809682853000, - "key": "gatsby-mdx-entire-payload-fb7375c64a5b69bbc2f3ed91d99452df-", - "val": { - "mdast": { - "type": "root", - "children": [ - { - "type": "heading", - "depth": 1, - "children": [ - { - "type": "text", - "value": "Hello", - "position": { - "start": { "line": 2, "column": 3, "offset": 3 }, - "end": { "line": 2, "column": 8, "offset": 8 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 2, "column": 1, "offset": 1 }, - "end": { "line": 2, "column": 8, "offset": 8 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 4, "column": 1, "offset": 10 }, - "end": { "line": 4, "column": 4, "offset": 13 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "This is the MDX Deck Gatsby theme", - "position": { - "start": { "line": 6, "column": 1, "offset": 15 }, - "end": { "line": 6, "column": 34, "offset": 48 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 6, "column": 1, "offset": 15 }, - "end": { "line": 6, "column": 34, "offset": 48 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 8, "column": 1, "offset": 50 }, - "end": { "line": 8, "column": 4, "offset": 53 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "npm i @mdx-deck/gatsby-theme", - "position": { - "start": { "line": 10, "column": 1, "offset": 55 }, - "end": { "line": 10, "column": 31, "offset": 85 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 10, "column": 1, "offset": 55 }, - "end": { "line": 10, "column": 31, "offset": 85 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 12, "column": 1, "offset": 87 }, - "end": { "line": 12, "column": 4, "offset": 90 }, - "indent": [] - } - }, - { - "type": "code", - "lang": "js", - "meta": null, - "value": "// gatsby-config.js\nmodule.exports = {\n __experimentalThemes: [\n '@mdx-deck/gatsby-theme',\n ]\n}", - "position": { - "start": { "line": 14, "column": 1, "offset": 92 }, - "end": { "line": 21, "column": 4, "offset": 202 }, - "indent": [1, 1, 1, 1, 1, 1, 1] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 23, "column": 1, "offset": 204 }, - "end": { "line": 23, "column": 4, "offset": 207 }, - "indent": [] - } - }, - { - "type": "paragraph", - "children": [ - { - "type": "inlineCode", - "value": "mkdir src src/decks", - "position": { - "start": { "line": 25, "column": 1, "offset": 209 }, - "end": { "line": 25, "column": 22, "offset": 230 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 25, "column": 1, "offset": 209 }, - "end": { "line": 25, "column": 22, "offset": 230 }, - "indent": [] - } - }, - { - "type": "thematicBreak", - "position": { - "start": { "line": 27, "column": 1, "offset": 232 }, - "end": { "line": 27, "column": 4, "offset": 235 }, - "indent": [] - } - }, - { - "type": "list", - "ordered": true, - "start": 1, - "spread": false, - "children": [ - { - "type": "listItem", - "spread": false, - "checked": null, - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Add an MDX deck to ", - "position": { - "start": { "line": 29, "column": 4, "offset": 240 }, - "end": { "line": 29, "column": 23, "offset": 259 }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "src/decks", - "position": { - "start": { "line": 29, "column": 23, "offset": 259 }, - "end": { "line": 29, "column": 34, "offset": 270 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 29, "column": 4, "offset": 240 }, - "end": { "line": 29, "column": 34, "offset": 270 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 29, "column": 1, "offset": 237 }, - "end": { "line": 29, "column": 34, "offset": 270 }, - "indent": [] - } - }, - { - "type": "listItem", - "spread": false, - "checked": null, - "children": [ - { - "type": "paragraph", - "children": [ - { - "type": "text", - "value": "Navigate to ", - "position": { - "start": { "line": 30, "column": 4, "offset": 274 }, - "end": { "line": 30, "column": 16, "offset": 286 }, - "indent": [] - } - }, - { - "type": "inlineCode", - "value": "http://localhost.com/decks", - "position": { - "start": { "line": 30, "column": 16, "offset": 286 }, - "end": { "line": 30, "column": 44, "offset": 314 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 30, "column": 4, "offset": 274 }, - "end": { "line": 30, "column": 44, "offset": 314 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 30, "column": 1, "offset": 271 }, - "end": { "line": 30, "column": 44, "offset": 314 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 29, "column": 1, "offset": 237 }, - "end": { "line": 30, "column": 44, "offset": 314 }, - "indent": [1] - } - }, - { - "type": "export", - "value": "export const _frontmatter = {}", - "position": { - "start": { "line": 34, "column": 1, "offset": 318 }, - "end": { "line": 34, "column": 31, "offset": 348 }, - "indent": [] - } - } - ], - "position": { - "start": { "line": 1, "column": 1, "offset": 0 }, - "end": { "line": 34, "column": 31, "offset": 348 } - } - }, - "scopeImports": ["import React from 'react'"], - "scopeIdentifiers": ["React"], - "body": "function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {};\nvar layoutProps = {\n _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n var components = _ref.components,\n props = _objectWithoutProperties(_ref, [\"components\"]);\n\n return mdx(MDXLayout, _extends({}, layoutProps, props, {\n components: components\n }), mdx(\"h1\", null, \"Hello\"), mdx(\"hr\", null), mdx(\"p\", null, \"This is the MDX Deck Gatsby theme\"), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"npm i @mdx-deck/gatsby-theme\")), mdx(\"hr\", null), mdx(\"pre\", null, mdx(\"code\", _extends({\n parentName: \"pre\"\n }, {\n \"className\": \"language-js\"\n }), \"// gatsby-config.js\\nmodule.exports = {\\n __experimentalThemes: [\\n '@mdx-deck/gatsby-theme',\\n ]\\n}\\n\")), mdx(\"hr\", null), mdx(\"p\", null, mdx(\"inlineCode\", {\n parentName: \"p\"\n }, \"mkdir src src/decks\")), mdx(\"hr\", null), mdx(\"ol\", null, mdx(\"li\", {\n parentName: \"ol\"\n }, \"Add an MDX deck to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"src/decks\")), mdx(\"li\", {\n parentName: \"ol\"\n }, \"Navigate to \", mdx(\"inlineCode\", {\n parentName: \"li\"\n }, \"http://localhost.com/decks\"))));\n}\nMDXContent.isMDXComponent = true;", - "rawMDXOutput": "/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\n\nexport const _frontmatter = {}\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({ components, ...props }) {\n return (\n \n

{`Hello`}

\n
\n

{`This is the MDX Deck Gatsby theme`}

\n
\n

{`npm i @mdx-deck/gatsby-theme`}

\n
\n
{`// gatsby-config.js\nmodule.exports = {\n  __experimentalThemes: [\n    '@mdx-deck/gatsby-theme',\n  ]\n}\n`}
\n
\n

{`mkdir src src/decks`}

\n
\n
    \n
  1. {`Add an MDX deck to `}{`src/decks`}
  2. \n
  3. {`Navigate to `}{`http://localhost.com/decks`}
  4. \n
\n\n \n )\n}\nMDXContent.isMDXComponent = true" - } -} diff --git a/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js b/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js deleted file mode 100644 index fa770bb..0000000 --- a/packages/gatsby-theme/.cache/caches/gatsby-mdx/mdx-scopes-dir/1970366a8c100bb8e42caab4bfa24659.js +++ /dev/null @@ -1,4 +0,0 @@ -import React from 'react' -export default { - React, -} diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js b/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js deleted file mode 100644 index 3346f3b..0000000 --- a/packages/gatsby-theme/.cache/commonjs/api-runner-browser-plugins.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict' - -// During bootstrap, we write requires at top of this file which looks -// basically like: -// module.exports = [ -// { -// plugin: require("/path/to/plugin1/gatsby-browser.js"), -// options: { ... }, -// }, -// { -// plugin: require("/path/to/plugin2/gatsby-browser.js"), -// options: { ... }, -// }, -// ] -module.exports = [] diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js b/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js deleted file mode 100644 index 45c9a81..0000000 --- a/packages/gatsby-theme/.cache/commonjs/api-runner-browser.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict' - -const plugins = require(`./api-runner-browser-plugins`) - -const _require$publicLoader = require(`./loader`).publicLoader, - getResourcesForPathname = _require$publicLoader.getResourcesForPathname, - getResourcesForPathnameSync = - _require$publicLoader.getResourcesForPathnameSync, - getResourceURLsForPathname = _require$publicLoader.getResourceURLsForPathname - -exports.apiRunner = (api, args = {}, defaultReturn, argTransform) => { - // Hooks for gatsby-cypress's API handler - if (process.env.CYPRESS_SUPPORT) { - if (window.___apiHandler) { - window.___apiHandler(api) - } else if (window.___resolvedAPIs) { - window.___resolvedAPIs.push(api) - } else { - window.___resolvedAPIs = [api] - } - } - - let results = plugins.map(plugin => { - if (!plugin.plugin[api]) { - return undefined - } - - args.getResourcesForPathnameSync = getResourcesForPathnameSync - args.getResourcesForPathname = getResourcesForPathname - args.getResourceURLsForPathname = getResourceURLsForPathname - const result = plugin.plugin[api](args, plugin.options) - - if (result && argTransform) { - args = argTransform({ - args, - result, - plugin, - }) - } - - return result - }) // Filter out undefined results. - - results = results.filter(result => typeof result !== `undefined`) - - if (results.length > 0) { - return results - } else if (defaultReturn) { - return [defaultReturn] - } else { - return [] - } -} - -exports.apiRunnerAsync = (api, args, defaultReturn) => - plugins.reduce( - (previous, next) => - next.plugin[api] - ? previous.then(() => next.plugin[api](args, next.options)) - : previous, - Promise.resolve() - ) diff --git a/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js b/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js deleted file mode 100644 index c41f965..0000000 --- a/packages/gatsby-theme/.cache/commonjs/api-runner-ssr.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' - -// During bootstrap, we write requires at top of this file which looks like: -// var plugins = [ -// { -// plugin: require("/path/to/plugin1/gatsby-ssr.js"), -// options: { ... }, -// }, -// { -// plugin: require("/path/to/plugin2/gatsby-ssr.js"), -// options: { ... }, -// }, -// ] -const apis = require(`./api-ssr-docs`) // Run the specified API in any plugins that have implemented it - -module.exports = (api, args, defaultReturn, argTransform) => { - if (!apis[api]) { - console.log(`This API doesn't exist`, api) - } // Run each plugin in series. - // eslint-disable-next-line no-undef - - let results = plugins.map(plugin => { - if (!plugin.plugin[api]) { - return undefined - } - - const result = plugin.plugin[api](args, plugin.options) - - if (result && argTransform) { - args = argTransform({ - args, - result, - }) - } - - return result - }) // Filter out undefined results. - - results = results.filter(result => typeof result !== `undefined`) - - if (results.length > 0) { - return results - } else { - return [defaultReturn] - } -} diff --git a/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js b/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js deleted file mode 100644 index e8e6686..0000000 --- a/packages/gatsby-theme/.cache/commonjs/api-ssr-docs.js +++ /dev/null @@ -1,183 +0,0 @@ -'use strict' - -/** - * Replace the default server renderer. This is useful for integration with - * Redux, css-in-js libraries, etc. that need custom setups for server - * rendering. - * @param {Object} $0 - * @param {function} $0.replaceBodyHTMLString Call this with the HTML string - * you render. **WARNING** if multiple plugins implement this API it's the - * last plugin that "wins". TODO implement an automated warning against this. - * @param {function} $0.setHeadComponents Takes an array of components as its - * first argument which are added to the `headComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setHtmlAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setBodyAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setPreBodyComponents Takes an array of components as its - * first argument which are added to the `preBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setPostBodyComponents Takes an array of components as its - * first argument which are added to the `postBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setBodyProps Takes an object of data which - * is merged with other body props and passed to `html.js` as `bodyProps`. - * @param {Object} pluginOptions - * @example - * // From gatsby-plugin-glamor - * const { renderToString } = require("react-dom/server") - * const inline = require("glamor-inline") - * - * exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { - * const bodyHTML = renderToString(bodyComponent) - * const inlinedHTML = inline(bodyHTML) - * - * replaceBodyHTMLString(inlinedHTML) - * } - */ -exports.replaceRenderer = true -/** - * Called after every page Gatsby server renders while building HTML so you can - * set head and body components to be rendered in your `html.js`. - * - * Gatsby does a two-pass render for HTML. It loops through your pages first - * rendering only the body and then takes the result body HTML string and - * passes it as the `body` prop to your `html.js` to complete the render. - * - * It's often handy to be able to send custom components to your `html.js`. - * For example, it's a very common pattern for React.js libraries that - * support server rendering to pull out data generated during the render to - * add to your HTML. - * - * Using this API over [`replaceRenderer`](#replaceRenderer) is preferable as - * multiple plugins can implement this API where only one plugin can take - * over server rendering. However, if your plugin requires taking over server - * rendering then that's the one to - * use - * @param {Object} $0 - * @param {string} $0.pathname The pathname of the page currently being rendered. - * @param {function} $0.setHeadComponents Takes an array of components as its - * first argument which are added to the `headComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setHtmlAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setBodyAttributes Takes an object of props which will - * spread into the `` component. - * @param {function} $0.setPreBodyComponents Takes an array of components as its - * first argument which are added to the `preBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setPostBodyComponents Takes an array of components as its - * first argument which are added to the `postBodyComponents` array which is passed - * to the `html.js` component. - * @param {function} $0.setBodyProps Takes an object of data which - * is merged with other body props and passed to `html.js` as `bodyProps`. - * @param {Object} pluginOptions - * @example - * const { Helmet } = require("react-helmet") - * - * exports.onRenderBody = ( - * { setHeadComponents, setHtmlAttributes, setBodyAttributes }, - * pluginOptions - * ) => { - * const helmet = Helmet.renderStatic() - * setHtmlAttributes(helmet.htmlAttributes.toComponent()) - * setBodyAttributes(helmet.bodyAttributes.toComponent()) - * setHeadComponents([ - * helmet.title.toComponent(), - * helmet.link.toComponent(), - * helmet.meta.toComponent(), - * helmet.noscript.toComponent(), - * helmet.script.toComponent(), - * helmet.style.toComponent(), - * ]) - * } - */ - -exports.onRenderBody = true -/** - * Called after every page Gatsby server renders while building HTML so you can - * replace head components to be rendered in your `html.js`. This is useful if - * you need to reorder scripts or styles added by other plugins. - * @param {Object} $0 - * @param {Array} $0.getHeadComponents Returns the current `headComponents` array. - * @param {function} $0.replaceHeadComponents Takes an array of components as its - * first argument which replace the `headComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Array} $0.getPreBodyComponents Returns the current `preBodyComponents` array. - * @param {function} $0.replacePreBodyComponents Takes an array of components as its - * first argument which replace the `preBodyComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Array} $0.getPostBodyComponents Returns the current `postBodyComponents` array. - * @param {function} $0.replacePostBodyComponents Takes an array of components as its - * first argument which replace the `postBodyComponents` array which is passed - * to the `html.js` component. **WARNING** if multiple plugins implement this - * API it's the last plugin that "wins". - * @param {Object} pluginOptions - * @example - * // Move Typography.js styles to the top of the head section so they're loaded first. - * exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => { - * const headComponents = getHeadComponents() - * headComponents.sort((x, y) => { - * if (x.key === 'TypographyStyle') { - * return -1 - * } else if (y.key === 'TypographyStyle') { - * return 1 - * } - * return 0 - * }) - * replaceHeadComponents(headComponents) - * } - */ - -exports.onPreRenderHTML = true -/** - * Allow a plugin to wrap the page element. - * - * This is useful for setting wrapper component around pages that won't get - * unmounted on page change. For setting Provider components use [wrapRootElement](#wrapRootElement). - * - * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapPageElement) - * @param {object} $0 - * @param {ReactNode} $0.element The "Page" React Element built by Gatsby. - * @param {object} $0.props Props object used by page. - * @example - * import React from "react" - * import Layout from "./src/components/layout" - * - * export const wrapPageElement = ({ element, props }) => { - * // props provide same data to Layout as Page element will get - * // including location, data, etc - you don't need to pass it - * return {element} - * } - */ - -exports.wrapPageElement = true -/** - * Allow a plugin to wrap the root element. - * - * This is useful to setup any Providers component that will wrap your application. - * For setting persistent UI elements around pages use [wrapPageElement](#wrapPageElement). - * - * _Note:_ [There is equivalent hook in Browser API](/docs/browser-apis/#wrapRootElement) - * @param {object} $0 - * @param {ReactNode} $0.element The "Root" React Element built by Gatsby. - * @example - * import React from "react" - * import { Provider } from "react-redux" - * - * import createStore from "./src/state/createStore" - * const store = createStore() - * - * export const wrapRootElement = ({ element }) => { - * return ( - * - * {element} - * - * ) - * } - */ - -exports.wrapRootElement = true diff --git a/packages/gatsby-theme/.cache/commonjs/app.js b/packages/gatsby-theme/.cache/commonjs/app.js deleted file mode 100644 index 7048393..0000000 --- a/packages/gatsby-theme/.cache/commonjs/app.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict' - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -var _react = _interopRequireDefault(require('react')) - -var _reactDom = _interopRequireDefault(require('react-dom')) - -var _domready = _interopRequireDefault(require('@mikaelkristiansson/domready')) - -var _socketIo = _interopRequireDefault(require('./socketIo')) - -var _emitter = _interopRequireDefault(require('./emitter')) - -var _apiRunnerBrowser = require('./api-runner-browser') - -var _loader = _interopRequireWildcard(require('./loader')) - -var _syncRequires = _interopRequireDefault(require('./sync-requires')) - -var _pages = _interopRequireDefault(require('./pages.json')) - -window.___emitter = _emitter.default -;(0, _loader.setApiRunnerForLoader)(_apiRunnerBrowser.apiRunner) // Let the site/plugins run code very early. - -;(0, _apiRunnerBrowser.apiRunnerAsync)(`onClientEntry`).then(() => { - // Hook up the client to socket.io on server - const socket = (0, _socketIo.default)() - - if (socket) { - socket.on(`reload`, () => { - window.location.reload() - }) - } - /** - * Service Workers are persistent by nature. They stick around, - * serving a cached version of the site if they aren't removed. - * This is especially frustrating when you need to test the - * production build on your local machine. - * - * Let's unregister the service workers in development, and tidy up a few errors. - */ - - if (supportsServiceWorkers(location, navigator)) { - navigator.serviceWorker.getRegistrations().then(registrations => { - for ( - var _iterator = registrations, - _isArray = Array.isArray(_iterator), - _i = 0, - _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); - ; - - ) { - var _ref - - if (_isArray) { - if (_i >= _iterator.length) break - _ref = _iterator[_i++] - } else { - _i = _iterator.next() - if (_i.done) break - _ref = _i.value - } - - let registration = _ref - registration.unregister() - } - }) - } - - const rootElement = document.getElementById(`___gatsby`) - const renderer = (0, _apiRunnerBrowser.apiRunner)( - `replaceHydrateFunction`, - undefined, - _reactDom.default.render - )[0] - - _loader.default.addPagesArray(_pages.default) - - _loader.default.addDevRequires(_syncRequires.default) - - _loader.default.getResourcesForPathname(window.location.pathname).then(() => { - const preferDefault = m => (m && m.default) || m - - let Root = preferDefault(require(`./root`)) - ;(0, _domready.default)(() => { - renderer(_react.default.createElement(Root, null), rootElement, () => { - ;(0, _loader.postInitialRenderWork)() - ;(0, _apiRunnerBrowser.apiRunner)(`onInitialClientRender`) - }) - }) - }) -}) - -function supportsServiceWorkers(location, navigator) { - if (location.hostname === `localhost` || location.protocol === `https:`) { - return `serviceWorker` in navigator - } - - return false -} diff --git a/packages/gatsby-theme/.cache/commonjs/create-react-context.js b/packages/gatsby-theme/.cache/commonjs/create-react-context.js deleted file mode 100644 index a21f187..0000000 --- a/packages/gatsby-theme/.cache/commonjs/create-react-context.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _default = _react.default.createContext -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/default-html.js b/packages/gatsby-theme/.cache/commonjs/default-html.js deleted file mode 100644 index 78880d9..0000000 --- a/packages/gatsby-theme/.cache/commonjs/default-html.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = HTML - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -function HTML(props) { - return _react.default.createElement( - 'html', - props.htmlAttributes, - _react.default.createElement( - 'head', - null, - _react.default.createElement('meta', { - charSet: 'utf-8', - }), - _react.default.createElement('meta', { - httpEquiv: 'x-ua-compatible', - content: 'ie=edge', - }), - _react.default.createElement('meta', { - name: 'viewport', - content: 'width=device-width, initial-scale=1, shrink-to-fit=no', - }), - props.headComponents - ), - _react.default.createElement( - 'body', - props.bodyAttributes, - props.preBodyComponents, - _react.default.createElement( - 'noscript', - { - key: 'noscript', - id: 'gatsby-noscript', - }, - 'This app works best with JavaScript enabled.' - ), - _react.default.createElement('div', { - key: `body`, - id: '___gatsby', - dangerouslySetInnerHTML: { - __html: props.body, - }, - }), - props.postBodyComponents - ) - ) -} - -HTML.propTypes = { - htmlAttributes: _propTypes.default.object, - headComponents: _propTypes.default.array, - bodyAttributes: _propTypes.default.object, - preBodyComponents: _propTypes.default.array, - body: _propTypes.default.string, - postBodyComponents: _propTypes.default.array, -} diff --git a/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js b/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js deleted file mode 100644 index c49bf48..0000000 --- a/packages/gatsby-theme/.cache/commonjs/develop-static-entry.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _server = require('react-dom/server') - -var _lodash = require('lodash') - -var _apiRunnerSsr = _interopRequireDefault(require('./api-runner-ssr')) - -// import testRequireError from "./test-require-error" -// For some extremely mysterious reason, webpack adds the above module *after* -// this module so that when this code runs, testRequireError is undefined. -// So in the meantime, we'll just inline it. -const testRequireError = (moduleName, err) => { - const regex = new RegExp(`Error: Cannot find module\\s.${moduleName}`) - const firstLine = err.toString().split(`\n`)[0] - return regex.test(firstLine) -} - -let Html - -try { - Html = require(`../src/html`) -} catch (err) { - if (testRequireError(`../src/html`, err)) { - Html = require(`./default-html`) - } else { - console.log(`There was an error requiring "src/html.js"\n\n`, err, `\n\n`) - process.exit() - } -} - -Html = Html && Html.__esModule ? Html.default : Html - -var _default = (pagePath, callback) => { - let headComponents = [] - let htmlAttributes = {} - let bodyAttributes = {} - let preBodyComponents = [] - let postBodyComponents = [] - let bodyProps = {} - let htmlStr - - const setHeadComponents = components => { - headComponents = headComponents.concat(components) - } - - const setHtmlAttributes = attributes => { - htmlAttributes = (0, _lodash.merge)(htmlAttributes, attributes) - } - - const setBodyAttributes = attributes => { - bodyAttributes = (0, _lodash.merge)(bodyAttributes, attributes) - } - - const setPreBodyComponents = components => { - preBodyComponents = preBodyComponents.concat(components) - } - - const setPostBodyComponents = components => { - postBodyComponents = postBodyComponents.concat(components) - } - - const setBodyProps = props => { - bodyProps = (0, _lodash.merge)({}, bodyProps, props) - } - - const getHeadComponents = () => headComponents - - const replaceHeadComponents = components => { - headComponents = components - } - - const getPreBodyComponents = () => preBodyComponents - - const replacePreBodyComponents = components => { - preBodyComponents = components - } - - const getPostBodyComponents = () => postBodyComponents - - const replacePostBodyComponents = components => { - postBodyComponents = components - } - - ;(0, _apiRunnerSsr.default)(`onRenderBody`, { - setHeadComponents, - setHtmlAttributes, - setBodyAttributes, - setPreBodyComponents, - setPostBodyComponents, - setBodyProps, - }) - ;(0, _apiRunnerSsr.default)(`onPreRenderHTML`, { - getHeadComponents, - replaceHeadComponents, - getPreBodyComponents, - replacePreBodyComponents, - getPostBodyComponents, - replacePostBodyComponents, - }) - - const htmlElement = _react.default.createElement( - Html, - Object.assign({}, bodyProps, { - body: ``, - headComponents: headComponents.concat([ - _react.default.createElement('script', { - key: `io`, - src: '/socket.io/socket.io.js', - }), - ]), - htmlAttributes, - bodyAttributes, - preBodyComponents, - postBodyComponents: postBodyComponents.concat([ - _react.default.createElement('script', { - key: `commons`, - src: '/commons.js', - }), - ]), - }) - ) - - htmlStr = (0, _server.renderToStaticMarkup)(htmlElement) - htmlStr = `${htmlStr}` - callback(null, htmlStr) -} - -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/emitter.js b/packages/gatsby-theme/.cache/commonjs/emitter.js deleted file mode 100644 index bc82dbb..0000000 --- a/packages/gatsby-theme/.cache/commonjs/emitter.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _mitt = _interopRequireDefault(require('mitt')) - -const emitter = (0, _mitt.default)() -var _default = emitter -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/ensure-resources.js b/packages/gatsby-theme/.cache/commonjs/ensure-resources.js deleted file mode 100644 index 877b4ab..0000000 --- a/packages/gatsby-theme/.cache/commonjs/ensure-resources.js +++ /dev/null @@ -1,154 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _loader = _interopRequireDefault(require('./loader')) - -var _shallowCompare = _interopRequireDefault(require('shallow-compare')) - -let isInitialRender = true // Pass pathname in as prop. -// component will try fetching resources. If they exist, -// will just render, else will render null. -// It will also wait for pageResources -// before propagating location change to children. - -class EnsureResources extends _react.default.Component { - constructor(props) { - super() - let location = props.location - this.state = { - location: Object.assign({}, location), - pageResources: _loader.default.getResourcesForPathnameSync( - location.pathname - ), - } - } - - reloadPage(prevHref) { - // Do this, rather than simply `window.location.reload()`, so that - // pressing the back/forward buttons work - otherwise when pressing - // back, the browser will just change the URL and expect JS to handle - // the change, which won't always work since it might not be a Gatsby - // page. - const href = window.location.href - window.history.replaceState({}, ``, prevHref) - window.location.replace(href) - } - - static getDerivedStateFromProps({ location }, prevState) { - if (prevState.location !== location) { - const pageResources = _loader.default.getResourcesForPathnameSync( - location.pathname - ) - - return { - pageResources, - location: Object.assign({}, location), - } - } - - return null - } - - hasResources(pageResources) { - if (pageResources && pageResources.json) { - return true - } - - if (pageResources && process.env.NODE_ENV !== `production`) { - return true - } - - return false - } - - retryResources(nextProps) { - const pathname = nextProps.location.pathname - - if (!_loader.default.getResourcesForPathnameSync(pathname)) { - // Store the previous and next location before resolving resources - const prevLocation = this.props.location - this.nextLocation = nextProps.location // Page resources won't be set in cases where the browser back button - // or forward button is pushed as we can't wait as normal for resources - // to load before changing the page. - - _loader.default.getResourcesForPathname(pathname).then(pageResources => { - // The page may have changed since we started this, in which case doesn't update - if (this.nextLocation !== nextProps.location) { - return - } - - if (this.hasResources(pageResources)) { - this.setState({ - location: Object.assign({}, window.location), - pageResources, - }) - return - } // If we still don't have resources, reload the page. - // (This won't happen on initial render, since shouldComponentUpdate - // is only called when the component updates.) - - this.reloadPage(prevLocation.href) - }) - } - } - - shouldComponentUpdate(nextProps, nextState) { - // Always return false if we're missing resources. - if (!this.hasResources(nextState.pageResources)) { - this.retryResources(nextProps) - return false - } // Check if the component or json have changed. - - if (this.state.pageResources !== nextState.pageResources) { - return true - } - - if ( - this.state.pageResources.component !== nextState.pageResources.component - ) { - return true - } - - if (this.state.pageResources.json !== nextState.pageResources.json) { - return true - } // Check if location has changed on a page using internal routing - // via matchPath configuration. - - if ( - this.state.location.key !== nextState.location.key && - nextState.pageResources.page && - (nextState.pageResources.page.matchPath || - nextState.pageResources.page.path) - ) { - return true - } - - return (0, _shallowCompare.default)(this, nextProps, nextState) - } - - render() { - if (!this.hasResources(this.state.pageResources) && isInitialRender) { - window.___failedResources = true // prevent hydrating - - throw new Error(`Missing resources for ${this.state.location.pathname}`) - } - - isInitialRender = false - return this.props.children(this.state) - } -} - -EnsureResources.propTypes = { - location: _propTypes.default.object.isRequired, - pageResources: _propTypes.default.object, -} -var _default = EnsureResources -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js b/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js deleted file mode 100644 index cb0bfc4..0000000 --- a/packages/gatsby-theme/.cache/commonjs/error-overlay-handler.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict' - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -exports.__esModule = true -exports.errorMap = exports.reportError = exports.clearError = void 0 - -var ErrorOverlay = _interopRequireWildcard(require('react-error-overlay')) - -// Report runtime errors -ErrorOverlay.startReportingRuntimeErrors({ - onError: () => {}, - filename: `/commons.js`, -}) -ErrorOverlay.setEditorHandler(errorLocation => - window.fetch( - `/__open-stack-frame-in-editor?fileName=` + - window.encodeURIComponent(errorLocation.fileName) + - `&lineNumber=` + - window.encodeURIComponent(errorLocation.lineNumber || 1) - ) -) -const errorMap = {} -exports.errorMap = errorMap - -const handleErrorOverlay = () => { - const errors = Object.values(errorMap) - - if (errors.length > 0) { - const errorMsg = errors.join(`\n\n`) - ErrorOverlay.reportBuildError(errorMsg) - } else { - ErrorOverlay.dismissBuildError() - } -} - -const clearError = errorID => { - delete errorMap[errorID] - handleErrorOverlay() -} - -exports.clearError = clearError - -const reportError = (errorID, error) => { - if (error) { - errorMap[errorID] = error - } - - handleErrorOverlay() -} - -exports.reportError = reportError diff --git a/packages/gatsby-theme/.cache/commonjs/find-page.js b/packages/gatsby-theme/.cache/commonjs/find-page.js deleted file mode 100644 index 4031364..0000000 --- a/packages/gatsby-theme/.cache/commonjs/find-page.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _utils = require('@reach/router/lib/utils') - -var _stripPrefix = _interopRequireDefault(require('./strip-prefix')) - -// TODO add tests especially for handling prefixed links. -const pageCache = {} - -var _default = (pages, pathPrefix = ``) => rawPathname => { - let pathname = decodeURIComponent(rawPathname) // Remove the pathPrefix from the pathname. - - let trimmedPathname = (0, _stripPrefix.default)(pathname, pathPrefix) // Remove any hashfragment - - if (trimmedPathname.split(`#`).length > 1) { - trimmedPathname = trimmedPathname - .split(`#`) - .slice(0, -1) - .join(``) - } // Remove search query - - if (trimmedPathname.split(`?`).length > 1) { - trimmedPathname = trimmedPathname - .split(`?`) - .slice(0, -1) - .join(``) - } - - if (pageCache[trimmedPathname]) { - return pageCache[trimmedPathname] - } - - let foundPage // Array.prototype.find is not supported in IE so we use this somewhat odd - // work around. - - pages.some(page => { - let pathToMatch = page.matchPath ? page.matchPath : page.path - - if ((0, _utils.match)(pathToMatch, trimmedPathname)) { - foundPage = page - pageCache[trimmedPathname] = page - return true - } // Finally, try and match request with default document. - - if ((0, _utils.match)(`${page.path}index.html`, trimmedPathname)) { - foundPage = page - pageCache[trimmedPathname] = page - return true - } - - return false - }) - return foundPage -} - -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js b/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js deleted file mode 100644 index ac9665a..0000000 --- a/packages/gatsby-theme/.cache/commonjs/gatsby-browser-entry.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict' - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.graphql = graphql -exports.useStaticQuery = exports.StaticQuery = exports.StaticQueryContext = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _gatsbyLink = _interopRequireWildcard(require('gatsby-link')) - -exports.Link = _gatsbyLink.default -exports.withPrefix = _gatsbyLink.withPrefix -exports.navigate = _gatsbyLink.navigate -exports.push = _gatsbyLink.push -exports.replace = _gatsbyLink.replace -exports.navigateTo = _gatsbyLink.navigateTo -exports.parsePath = _gatsbyLink.parsePath - -var _publicPageRenderer = _interopRequireDefault( - require('./public-page-renderer') -) - -exports.PageRenderer = _publicPageRenderer.default - -const StaticQueryContext = _react.default.createContext({}) - -exports.StaticQueryContext = StaticQueryContext - -const StaticQuery = props => - _react.default.createElement( - StaticQueryContext.Consumer, - null, - staticQueryData => { - if ( - props.data || - (staticQueryData[props.query] && staticQueryData[props.query].data) - ) { - return (props.render || props.children)( - props.data ? props.data.data : staticQueryData[props.query].data - ) - } else { - return _react.default.createElement( - 'div', - null, - 'Loading (StaticQuery)' - ) - } - } - ) - -exports.StaticQuery = StaticQuery - -const useStaticQuery = query => { - if ( - typeof _react.default.useContext !== `function` && - process.env.NODE_ENV === `development` - ) { - throw new Error( - `You're likely using a version of React that doesn't support Hooks\n` + - `Please update React and ReactDOM to 16.8.0 or later to use the useStaticQuery hook.` - ) - } - - const context = _react.default.useContext(StaticQueryContext) - - if (context[query] && context[query].data) { - return context[query].data - } else { - throw new Error( - `The result of this StaticQuery could not be fetched.\n\n` + - `This is likely a bug in Gatsby and if refreshing the page does not fix it, ` + - `please open an issue in https://github.com/gatsbyjs/gatsby/issues` - ) - } -} - -exports.useStaticQuery = useStaticQuery -StaticQuery.propTypes = { - data: _propTypes.default.object, - query: _propTypes.default.string.isRequired, - render: _propTypes.default.func, - children: _propTypes.default.func, -} - -function graphql() { - throw new Error( - `It appears like Gatsby is misconfigured. Gatsby related \`graphql\` calls ` + - `are supposed to only be evaluated at compile time, and then compiled away,. ` + - `Unfortunately, something went wrong and the query was left in the compiled code.\n\n.` + - `Unless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby.` - ) -} diff --git a/packages/gatsby-theme/.cache/commonjs/json-store.js b/packages/gatsby-theme/.cache/commonjs/json-store.js deleted file mode 100644 index 786a21b..0000000 --- a/packages/gatsby-theme/.cache/commonjs/json-store.js +++ /dev/null @@ -1,128 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _extends2 = _interopRequireDefault( - require('@babel/runtime/helpers/extends') -) - -var _objectWithoutPropertiesLoose2 = _interopRequireDefault( - require('@babel/runtime/helpers/objectWithoutPropertiesLoose') -) - -var _defineProperty2 = _interopRequireDefault( - require('@babel/runtime/helpers/defineProperty') -) - -var _react = _interopRequireDefault(require('react')) - -var _pageRenderer = _interopRequireDefault(require('./page-renderer')) - -var _gatsby = require('gatsby') - -var _socketIo = require('./socketIo') - -if (process.env.NODE_ENV === `production`) { - throw new Error( - `It appears like Gatsby is misconfigured. JSONStore is Gatsby internal ` + - `development-only component and should never be used in production.\n\n` + - `Unless your site has a complex or custom webpack/Gatsby ` + - `configuration this is likely a bug in Gatsby. ` + - `Please report this at https://github.com/gatsbyjs/gatsby/issues ` + - `with steps to reproduce this error.` - ) -} - -const getPathFromProps = props => - props.pageResources && props.pageResources.page - ? props.pageResources.page.path - : undefined - -class JSONStore extends _react.default.Component { - constructor(props) { - super(props) - ;(0, _defineProperty2.default)(this, 'handleMittEvent', (type, event) => { - this.setState({ - staticQueryData: (0, _socketIo.getStaticQueryData)(), - pageQueryData: (0, _socketIo.getPageQueryData)(), - }) - }) - this.state = { - staticQueryData: (0, _socketIo.getStaticQueryData)(), - pageQueryData: (0, _socketIo.getPageQueryData)(), - path: null, - } - } - - componentDidMount() { - ;(0, _socketIo.registerPath)(getPathFromProps(this.props)) - - ___emitter.on(`*`, this.handleMittEvent) - } - - componentWillUnmount() { - ;(0, _socketIo.unregisterPath)(this.state.path) - - ___emitter.off(`*`, this.handleMittEvent) - } - - static getDerivedStateFromProps(props, state) { - const newPath = getPathFromProps(props) - - if (newPath !== state.path) { - ;(0, _socketIo.unregisterPath)(state.path) - ;(0, _socketIo.registerPath)(newPath) - return { - path: newPath, - } - } - - return null - } - - shouldComponentUpdate(nextProps, nextState) { - // We want to update this component when: - // - location changed - // - page data for path changed - // - static query results changed - return ( - this.props.location !== nextProps.location || - this.state.path !== nextState.path || - this.state.pageQueryData[nextState.path] !== - nextState.pageQueryData[nextState.path] || - this.state.staticQueryData !== nextState.staticQueryData - ) - } - - render() { - const data = this.state.pageQueryData[getPathFromProps(this.props)] // eslint-disable-next-line - - const _this$props = this.props, - pages = _this$props.pages, - propsWithoutPages = (0, _objectWithoutPropertiesLoose2.default)( - _this$props, - ['pages'] - ) - - if (!data) { - return _react.default.createElement('div', null) - } - - return _react.default.createElement( - _gatsby.StaticQueryContext.Provider, - { - value: this.state.staticQueryData, - }, - _react.default.createElement( - _pageRenderer.default, - (0, _extends2.default)({}, propsWithoutPages, data) - ) - ) - } -} - -var _default = JSONStore -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/loader.js b/packages/gatsby-theme/.cache/commonjs/loader.js deleted file mode 100644 index 0f108c9..0000000 --- a/packages/gatsby-theme/.cache/commonjs/loader.js +++ /dev/null @@ -1,449 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = exports.publicLoader = exports.setApiRunnerForLoader = exports.postInitialRenderWork = void 0 - -var _findPage = _interopRequireDefault(require('./find-page')) - -var _emitter = _interopRequireDefault(require('./emitter')) - -var _prefetch = _interopRequireDefault(require('./prefetch')) - -const preferDefault = m => (m && m.default) || m - -let devGetPageData -let inInitialRender = true -let hasFetched = Object.create(null) -let syncRequires = {} -let asyncRequires = {} -let jsonDataPaths = {} -let fetchHistory = [] -let fetchingPageResourceMapPromise = null -let fetchedPageResourceMap = false -/** - * Indicate if pages manifest is loaded - * - in production it is split to separate "pages-manifest" chunk that need to be lazy loaded, - * - in development it is part of single "common" chunk and is available from the start. - */ - -let hasPageResourceMap = process.env.NODE_ENV !== `production` -let apiRunner -const failedPaths = {} -const MAX_HISTORY = 5 -const jsonPromiseStore = {} - -if (process.env.NODE_ENV !== `production`) { - devGetPageData = require(`./socketIo`).getPageData -} -/** - * Fetch resource map (pages data and paths to json files with results of - * queries) - */ - -const fetchPageResourceMap = () => { - if (!fetchingPageResourceMapPromise) { - fetchingPageResourceMapPromise = new Promise(resolve => { - asyncRequires - .data() - .then(({ pages, dataPaths }) => { - // TODO — expose proper way to access this data from plugins. - // Need to come up with an API for plugins to access - // site info. - window.___dataPaths = dataPaths - queue.addPagesArray(pages) - queue.addDataPaths(dataPaths) - hasPageResourceMap = true - resolve((fetchedPageResourceMap = true)) - }) - .catch(e => { - console.warn( - `Failed to fetch pages manifest. Gatsby will reload on next navigation.` - ) // failed to grab pages metadata - // for now let's just resolve this - on navigation this will cause missing resources - // and will trigger page reload and then it will retry - // this can happen with service worker updates when webpack manifest points to old - // chunk that no longer exists on server - - resolve((fetchedPageResourceMap = true)) - }) - }) - } - - return fetchingPageResourceMapPromise -} - -const createJsonURL = jsonName => `${__PATH_PREFIX__}/static/d/${jsonName}.json` - -const createComponentUrls = componentChunkName => - window.___chunkMapping[componentChunkName].map( - chunk => __PATH_PREFIX__ + chunk - ) - -const fetchResource = resourceName => { - // Find resource - let resourceFunction - - if (resourceName.slice(0, 12) === `component---`) { - resourceFunction = asyncRequires.components[resourceName] - } else { - if (resourceName in jsonPromiseStore) { - resourceFunction = () => jsonPromiseStore[resourceName] - } else { - resourceFunction = () => { - const fetchPromise = new Promise((resolve, reject) => { - const url = createJsonURL(jsonDataPaths[resourceName]) - const req = new XMLHttpRequest() - req.open(`GET`, url, true) - req.withCredentials = true - - req.onreadystatechange = () => { - if (req.readyState == 4) { - if (req.status === 200) { - resolve(JSON.parse(req.responseText)) - } else { - delete jsonPromiseStore[resourceName] - reject() - } - } - } - - req.send(null) - }) - jsonPromiseStore[resourceName] = fetchPromise - return fetchPromise - } - } - } // Download the resource - - hasFetched[resourceName] = true - return new Promise(resolve => { - const fetchPromise = resourceFunction() - let failed = false - return fetchPromise - .catch(() => { - failed = true - }) - .then(component => { - fetchHistory.push({ - resource: resourceName, - succeeded: !failed, - }) - fetchHistory = fetchHistory.slice(-MAX_HISTORY) - resolve(component) - }) - }) -} - -const prefetchResource = resourceName => { - if (resourceName.slice(0, 12) === `component---`) { - return Promise.all( - createComponentUrls(resourceName).map(url => (0, _prefetch.default)(url)) - ) - } else { - const url = createJsonURL(jsonDataPaths[resourceName]) - return (0, _prefetch.default)(url) - } -} - -const getResourceModule = resourceName => - fetchResource(resourceName).then(preferDefault) - -const appearsOnLine = () => { - const isOnLine = navigator.onLine - - if (typeof isOnLine === `boolean`) { - return isOnLine - } // If no navigator.onLine support assume onLine if any of last N fetches succeeded - - const succeededFetch = fetchHistory.find(entry => entry.succeeded) - return !!succeededFetch -} - -const handleResourceLoadError = (path, message) => { - if (!failedPaths[path]) { - failedPaths[path] = message - } - - if ( - appearsOnLine() && - window.location.pathname.replace(/\/$/g, ``) !== path.replace(/\/$/g, ``) - ) { - window.location.pathname = path - } -} - -const onPrefetchPathname = pathname => { - if (!prefetchTriggered[pathname]) { - apiRunner(`onPrefetchPathname`, { - pathname, - }) - prefetchTriggered[pathname] = true - } -} - -const onPostPrefetchPathname = pathname => { - if (!prefetchCompleted[pathname]) { - apiRunner(`onPostPrefetchPathname`, { - pathname, - }) - prefetchCompleted[pathname] = true - } -} -/** - * Check if we should fallback to resources for 404 page if resources for a page are not found - * - * We can't do that when we don't have full pages manifest - we don't know if page exist or not if we don't have it. - * We also can't do that on initial render / mount in case we just can't load resources needed for first page. - * Not falling back to 404 resources will cause "EnsureResources" component to handle scenarios like this with - * potential reload - * @param {string} path Path to a page - */ - -const shouldFallbackTo404Resources = path => - (hasPageResourceMap || inInitialRender) && path !== `/404.html` // Note we're not actively using the path data atm. There -// could be future optimizations however around trying to ensure -// we load all resources for likely-to-be-visited paths. -// let pathArray = [] -// let pathCount = {} - -let findPage -let pathScriptsCache = {} -let prefetchTriggered = {} -let prefetchCompleted = {} -let disableCorePrefetching = false -const queue = { - addPagesArray: newPages => { - findPage = (0, _findPage.default)(newPages, __PATH_PREFIX__) - }, - addDevRequires: devRequires => { - syncRequires = devRequires - }, - addProdRequires: prodRequires => { - asyncRequires = prodRequires - }, - addDataPaths: dataPaths => { - jsonDataPaths = dataPaths - }, - // Hovering on a link is a very strong indication the user is going to - // click on it soon so let's start prefetching resources for this - // pathname. - hovering: path => { - queue.getResourcesForPathname(path) - }, - enqueue: path => { - if (!apiRunner) - console.error(`Run setApiRunnerForLoader() before enqueing paths`) // Skip prefetching if we know user is on slow or constrained connection - - if (`connection` in navigator) { - if ((navigator.connection.effectiveType || ``).includes(`2g`)) { - return false - } - - if (navigator.connection.saveData) { - return false - } - } // Tell plugins with custom prefetching logic that they should start - // prefetching this path. - - onPrefetchPathname(path) // If a plugin has disabled core prefetching, stop now. - - if (disableCorePrefetching.some(a => a)) { - return false - } // Check if the page exists. - - let page = findPage(path) // In production, we lazy load page metadata. If that - // hasn't been fetched yet, start fetching it now. - - if ( - process.env.NODE_ENV === `production` && - !page && - !fetchedPageResourceMap - ) { - // If page wasn't found check and we didn't fetch resources map for - // all pages, wait for fetch to complete and try find page again - return fetchPageResourceMap().then(() => queue.enqueue(path)) - } - - if (!page) { - return false - } - - if ( - process.env.NODE_ENV !== `production` && - process.env.NODE_ENV !== `test` - ) { - devGetPageData(page.path) - } // Prefetch resources. - - if (process.env.NODE_ENV === `production`) { - Promise.all([ - prefetchResource(page.jsonName), - prefetchResource(page.componentChunkName), - ]).then(() => { - // Tell plugins the path has been successfully prefetched - onPostPrefetchPathname(path) - }) - } - - return true - }, - getPage: pathname => findPage(pathname), - getResourceURLsForPathname: path => { - const page = findPage(path) - - if (page) { - return [ - ...createComponentUrls(page.componentChunkName), - createJsonURL(jsonDataPaths[page.jsonName]), - ] - } else { - return null - } - }, - getResourcesForPathnameSync: path => { - const page = findPage(path) - - if (page) { - return pathScriptsCache[page.path] - } else if (shouldFallbackTo404Resources(path)) { - return queue.getResourcesForPathnameSync(`/404.html`) - } else { - return null - } - }, - // Get resources (code/data) for a path. Fetches metdata first - // if necessary and then the code/data bundles. Used for prefetching - // and getting resources for page changes. - getResourcesForPathname: path => - new Promise((resolve, reject) => { - // Production code path - if (failedPaths[path]) { - handleResourceLoadError( - path, - `Previously detected load failure for "${path}"` - ) - reject() - return - } - - const page = findPage(path) // In production, we lazy load page metadata. If that - // hasn't been fetched yet, start fetching it now. - - if ( - !page && - !fetchedPageResourceMap && - process.env.NODE_ENV === `production` - ) { - // If page wasn't found check and we didn't fetch resources map for - // all pages, wait for fetch to complete and try to get resources again - fetchPageResourceMap().then(() => - resolve(queue.getResourcesForPathname(path)) - ) - return - } - - if (!page) { - if (shouldFallbackTo404Resources(path)) { - console.log(`A page wasn't found for "${path}"`) // Preload the custom 404 page - - resolve(queue.getResourcesForPathname(`/404.html`)) - return - } - - resolve() - return - } // Use the path from the page so the pathScriptsCache uses - // the normalized path. - - path = page.path // Check if it's in the cache already. - - if (pathScriptsCache[path]) { - _emitter.default.emit(`onPostLoadPageResources`, { - page, - pageResources: pathScriptsCache[path], - }) - - resolve(pathScriptsCache[path]) - return - } // Nope, we need to load resource(s) - - _emitter.default.emit(`onPreLoadPageResources`, { - path, - }) // In development we know the code is loaded already - // so we just return with it immediately. - - if (process.env.NODE_ENV !== `production`) { - const pageResources = { - component: syncRequires.components[page.componentChunkName], - page, // Add to the cache. - } - pathScriptsCache[path] = pageResources - devGetPageData(page.path).then(pageData => { - _emitter.default.emit(`onPostLoadPageResources`, { - page, - pageResources, - }) // Tell plugins the path has been successfully prefetched - - onPostPrefetchPathname(path) - resolve(pageResources) - }) - } else { - Promise.all([ - getResourceModule(page.componentChunkName), - getResourceModule(page.jsonName), - ]).then(([component, json]) => { - if (!(component && json)) { - resolve(null) - return - } - - const pageResources = { - component, - json, - page, - } - pageResources.page.jsonURL = createJsonURL( - jsonDataPaths[page.jsonName] - ) - pathScriptsCache[path] = pageResources - resolve(pageResources) - - _emitter.default.emit(`onPostLoadPageResources`, { - page, - pageResources, - }) // Tell plugins the path has been successfully prefetched - - onPostPrefetchPathname(path) - }) - } - }), -} - -const postInitialRenderWork = () => { - inInitialRender = false - - if (process.env.NODE_ENV === `production`) { - // We got all resources needed for first mount, - // we can fetch resources for all pages. - fetchPageResourceMap() - } -} - -exports.postInitialRenderWork = postInitialRenderWork - -const setApiRunnerForLoader = runner => { - apiRunner = runner - disableCorePrefetching = apiRunner(`disableCorePrefetching`) -} - -exports.setApiRunnerForLoader = setApiRunnerForLoader -const publicLoader = { - getResourcesForPathname: queue.getResourcesForPathname, - getResourceURLsForPathname: queue.getResourceURLsForPathname, - getResourcesForPathnameSync: queue.getResourcesForPathnameSync, -} -exports.publicLoader = publicLoader -var _default = queue -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/navigation.js b/packages/gatsby-theme/.cache/commonjs/navigation.js deleted file mode 100644 index 8d0eca2..0000000 --- a/packages/gatsby-theme/.cache/commonjs/navigation.js +++ /dev/null @@ -1,199 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.init = init -exports.shouldUpdateScroll = shouldUpdateScroll -exports.RouteUpdates = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _loader = _interopRequireDefault(require('./loader')) - -var _redirects = _interopRequireDefault(require('./redirects.json')) - -var _apiRunnerBrowser = require('./api-runner-browser') - -var _emitter = _interopRequireDefault(require('./emitter')) - -var _router = require('@reach/router') - -var _gatsbyLink = require('gatsby-link') - -// Convert to a map for faster lookup in maybeRedirect() -const redirectMap = _redirects.default.reduce((map, redirect) => { - map[redirect.fromPath] = redirect - return map -}, {}) - -function maybeRedirect(pathname) { - const redirect = redirectMap[pathname] - - if (redirect != null) { - if (process.env.NODE_ENV !== `production`) { - const pageResources = _loader.default.getResourcesForPathnameSync( - pathname - ) - - if (pageResources != null) { - console.error( - `The route "${pathname}" matches both a page and a redirect; this is probably not intentional.` - ) - } - } - - window.___replace(redirect.toPath) - - return true - } else { - return false - } -} - -const onPreRouteUpdate = (location, prevLocation) => { - if (!maybeRedirect(location.pathname)) { - ;(0, _apiRunnerBrowser.apiRunner)(`onPreRouteUpdate`, { - location, - prevLocation, - }) - } -} - -const onRouteUpdate = (location, prevLocation) => { - if (!maybeRedirect(location.pathname)) { - ;(0, _apiRunnerBrowser.apiRunner)(`onRouteUpdate`, { - location, - prevLocation, - }) // Temp hack while awaiting https://github.com/reach/router/issues/119 - - window.__navigatingToLink = false - } -} - -const navigate = (to, options = {}) => { - // Temp hack while awaiting https://github.com/reach/router/issues/119 - if (!options.replace) { - window.__navigatingToLink = true - } - - let _parsePath = (0, _gatsbyLink.parsePath)(to), - pathname = _parsePath.pathname - - const redirect = redirectMap[pathname] // If we're redirecting, just replace the passed in pathname - // to the one we want to redirect to. - - if (redirect) { - to = redirect.toPath - pathname = (0, _gatsbyLink.parsePath)(to).pathname - } // If we had a service worker update, no matter the path, reload window and - // reset the pathname whitelist - - if (window.___swUpdated) { - window.location = pathname - return - } // Start a timer to wait for a second before transitioning and showing a - // loader in case resources aren't around yet. - - const timeoutId = setTimeout(() => { - _emitter.default.emit(`onDelayedLoadPageResources`, { - pathname, - }) - - ;(0, _apiRunnerBrowser.apiRunner)(`onRouteUpdateDelayed`, { - location: window.location, - }) - }, 1000) - - _loader.default.getResourcesForPathname(pathname).then(pageResources => { - ;(0, _router.navigate)(to, options) - clearTimeout(timeoutId) - }) -} - -function shouldUpdateScroll(prevRouterProps, { location }) { - const pathname = location.pathname, - hash = location.hash - const results = (0, _apiRunnerBrowser.apiRunner)(`shouldUpdateScroll`, { - prevRouterProps, - // `pathname` for backwards compatibility - pathname, - routerProps: { - location, - }, - getSavedScrollPosition: args => this._stateStorage.read(args), - }) - - if (results.length > 0) { - return results[0] - } - - if (prevRouterProps) { - const oldPathname = prevRouterProps.location.pathname - - if (oldPathname === pathname) { - // Scroll to element if it exists, if it doesn't, or no hash is provided, - // scroll to top. - return hash ? hash.slice(1) : [0, 0] - } - } - - return true -} - -function init() { - // Temp hack while awaiting https://github.com/reach/router/issues/119 - window.__navigatingToLink = false - window.___loader = _loader.default - - window.___push = to => - navigate(to, { - replace: false, - }) - - window.___replace = to => - navigate(to, { - replace: true, - }) - - window.___navigate = (to, options) => navigate(to, options) // Check for initial page-load redirect - - maybeRedirect(window.location.pathname) -} // Fire on(Pre)RouteUpdate APIs - -class RouteUpdates extends _react.default.Component { - constructor(props) { - super(props) - onPreRouteUpdate(props.location, null) - } - - componentDidMount() { - onRouteUpdate(this.props.location, null) - } - - componentDidUpdate(prevProps, prevState, shouldFireRouteUpdate) { - if (shouldFireRouteUpdate) { - onRouteUpdate(this.props.location, prevProps.location) - } - } - - getSnapshotBeforeUpdate(prevProps) { - if (this.props.location.pathname !== prevProps.location.pathname) { - onPreRouteUpdate(this.props.location, prevProps.location) - return true - } - - return false - } - - render() { - return this.props.children - } -} - -exports.RouteUpdates = RouteUpdates -RouteUpdates.propTypes = { - location: _propTypes.default.object.isRequired, -} diff --git a/packages/gatsby-theme/.cache/commonjs/page-renderer.js b/packages/gatsby-theme/.cache/commonjs/page-renderer.js deleted file mode 100644 index 8053b41..0000000 --- a/packages/gatsby-theme/.cache/commonjs/page-renderer.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireWildcard(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _loader = require('./loader') - -var _apiRunnerBrowser = require('./api-runner-browser') - -// Renders page -class PageRenderer extends _react.default.Component { - render() { - const props = Object.assign({}, this.props, { - pathContext: this.props.pageContext, - }) - - const _apiRunner = (0, _apiRunnerBrowser.apiRunner)( - `replaceComponentRenderer`, - { - props: this.props, - loader: _loader.publicLoader, - } - ), - replacementElement = _apiRunner[0] - - const pageElement = - replacementElement || - (0, _react.createElement)( - this.props.pageResources.component, - Object.assign({}, props, { - key: this.props.pageResources.page.path, - }) - ) - const wrappedPage = (0, _apiRunnerBrowser.apiRunner)( - `wrapPageElement`, - { - element: pageElement, - props, - }, - pageElement, - ({ result }) => { - return { - element: result, - props, - } - } - ).pop() - return wrappedPage - } -} - -PageRenderer.propTypes = { - location: _propTypes.default.object.isRequired, - pageResources: _propTypes.default.object.isRequired, - data: _propTypes.default.object, - pageContext: _propTypes.default.object.isRequired, -} -var _default = PageRenderer -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/prefetch.js b/packages/gatsby-theme/.cache/commonjs/prefetch.js deleted file mode 100644 index 1515ac5..0000000 --- a/packages/gatsby-theme/.cache/commonjs/prefetch.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict' - -exports.__esModule = true -exports.default = void 0 - -const support = function support(feature) { - if (typeof document === `undefined`) { - return false - } - - const fakeLink = document.createElement(`link`) - - try { - if (fakeLink.relList && typeof fakeLink.relList.supports === `function`) { - return fakeLink.relList.supports(feature) - } - } catch (err) { - return false - } - - return false -} - -const linkPrefetchStrategy = function linkPrefetchStrategy(url) { - return new Promise((resolve, reject) => { - if (typeof document === `undefined`) { - reject() - return - } - - const link = document.createElement(`link`) - link.setAttribute(`rel`, `prefetch`) - link.setAttribute(`href`, url) - link.onload = resolve - link.onerror = reject - const parentElement = - document.getElementsByTagName(`head`)[0] || - document.getElementsByName(`script`)[0].parentNode - parentElement.appendChild(link) - }) -} - -const xhrPrefetchStrategy = function xhrPrefetchStrategy(url) { - return new Promise((resolve, reject) => { - const req = new XMLHttpRequest() - req.open(`GET`, url, true) - req.withCredentials = true - - req.onload = () => { - if (req.status === 200) { - resolve() - } else { - reject() - } - } - - req.send(null) - }) -} - -const supportedPrefetchStrategy = support(`prefetch`) - ? linkPrefetchStrategy - : xhrPrefetchStrategy -const preFetched = {} - -const prefetch = function prefetch(url) { - return new Promise(resolve => { - if (preFetched[url]) { - resolve() - return - } - - supportedPrefetchStrategy(url) - .then(() => { - resolve() - preFetched[url] = true - }) - .catch(() => {}) // 404s are logged to the console anyway - }) -} - -var _default = prefetch -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/production-app.js b/packages/gatsby-theme/.cache/commonjs/production-app.js deleted file mode 100644 index 9c6a697..0000000 --- a/packages/gatsby-theme/.cache/commonjs/production-app.js +++ /dev/null @@ -1,168 +0,0 @@ -'use strict' - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -var _extends2 = _interopRequireDefault( - require('@babel/runtime/helpers/extends') -) - -var _apiRunnerBrowser = require('./api-runner-browser') - -var _react = _interopRequireWildcard(require('react')) - -var _reactDom = _interopRequireDefault(require('react-dom')) - -var _router = require('@reach/router') - -var _utils = require('@reach/router/lib/utils') - -var _gatsbyReactRouterScroll = require('gatsby-react-router-scroll') - -var _domready = _interopRequireDefault(require('@mikaelkristiansson/domready')) - -var _navigation = require('./navigation') - -var _emitter = _interopRequireDefault(require('./emitter')) - -var _pageRenderer = _interopRequireDefault(require('./page-renderer')) - -var _asyncRequires = _interopRequireDefault(require('./async-requires')) - -var _loader = _interopRequireWildcard(require('./loader')) - -var _ensureResources = _interopRequireDefault(require('./ensure-resources')) - -window.asyncRequires = _asyncRequires.default -window.___emitter = _emitter.default -window.___loader = _loader.default - -_loader.default.addPagesArray([window.page]) - -_loader.default.addDataPaths({ - [window.page.jsonName]: window.dataPath, -}) - -_loader.default.addProdRequires(_asyncRequires.default) - -;(0, _loader.setApiRunnerForLoader)(_apiRunnerBrowser.apiRunner) -;(0, _navigation.init)() // Let the site/plugins run code very early. - -;(0, _apiRunnerBrowser.apiRunnerAsync)(`onClientEntry`).then(() => { - // Let plugins register a service worker. The plugin just needs - // to return true. - if ((0, _apiRunnerBrowser.apiRunner)(`registerServiceWorker`).length > 0) { - require(`./register-service-worker`) - } - - class RouteHandler extends _react.default.Component { - render() { - let location = this.props.location - return _react.default.createElement( - _ensureResources.default, - { - location: location, - }, - ({ pageResources, location }) => - _react.default.createElement( - _navigation.RouteUpdates, - { - location: location, - }, - _react.default.createElement( - _gatsbyReactRouterScroll.ScrollContext, - { - location: location, - shouldUpdateScroll: _navigation.shouldUpdateScroll, - }, - _react.default.createElement( - _pageRenderer.default, - (0, _extends2.default)( - {}, - this.props, - { - location: location, - pageResources: pageResources, - }, - pageResources.json - ) - ) - ) - ) - ) - } - } - - const _window = window, - page = _window.page, - browserLoc = _window.location - - if ( - // Make sure the window.page object is defined - page && // The canonical path doesn't match the actual path (i.e. the address bar) - __PATH_PREFIX__ + page.path !== browserLoc.pathname && // ...and if matchPage is specified, it also doesn't match the actual path - (!page.matchPath || - !(0, _utils.match)( - __PATH_PREFIX__ + page.matchPath, - browserLoc.pathname - )) && // Ignore 404 pages, since we want to keep the same URL - page.path !== `/404.html` && - !page.path.match(/^\/404\/?$/) && // Also ignore the offline shell (since when using the offline plugin, all - // pages have this canonical path) - !page.path.match(/^\/offline-plugin-app-shell-fallback\/?$/) - ) { - ;(0, _router.navigate)( - __PATH_PREFIX__ + page.path + browserLoc.search + browserLoc.hash, - { - replace: true, - } - ) - } - - _loader.default.getResourcesForPathname(browserLoc.pathname).then(() => { - const Root = () => - (0, _react.createElement)( - _router.Router, - { - basepath: __PATH_PREFIX__, - }, - (0, _react.createElement)(RouteHandler, { - path: `/*`, - }) - ) - - const WrappedRoot = (0, _apiRunnerBrowser.apiRunner)( - `wrapRootElement`, - { - element: _react.default.createElement(Root, null), - }, - _react.default.createElement(Root, null), - ({ result }) => { - return { - element: result, - } - } - ).pop() - - let NewRoot = () => WrappedRoot - - const renderer = (0, _apiRunnerBrowser.apiRunner)( - `replaceHydrateFunction`, - undefined, - _reactDom.default.hydrate - )[0] - ;(0, _domready.default)(() => { - renderer( - _react.default.createElement(NewRoot, null), - typeof window !== `undefined` - ? document.getElementById(`___gatsby`) - : void 0, - () => { - ;(0, _loader.postInitialRenderWork)() - ;(0, _apiRunnerBrowser.apiRunner)(`onInitialClientRender`) - } - ) - }) - }) -}) diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js deleted file mode 100644 index b5bc770..0000000 --- a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-dev.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _pages = _interopRequireDefault(require('./pages.json')) - -var _loader = _interopRequireDefault(require('./loader')) - -var _jsonStore = _interopRequireDefault(require('./json-store')) - -const DevPageRenderer = ({ location }) => { - const pageResources = _loader.default.getResourcesForPathnameSync( - location.pathname - ) - - return _react.default.createElement(_jsonStore.default, { - pages: _pages.default, - location, - pageResources, - }) -} - -DevPageRenderer.propTypes = { - location: _propTypes.default.shape({ - pathname: _propTypes.default.string.isRequired, - }).isRequired, -} -var _default = DevPageRenderer -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js deleted file mode 100644 index ec5a2cc..0000000 --- a/packages/gatsby-theme/.cache/commonjs/public-page-renderer-prod.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _react = _interopRequireDefault(require('react')) - -var _propTypes = _interopRequireDefault(require('prop-types')) - -var _pageRenderer = _interopRequireDefault(require('./page-renderer')) - -var _loader = _interopRequireDefault(require('./loader')) - -const ProdPageRenderer = ({ location }) => { - const pageResources = _loader.default.getResourcesForPathnameSync( - location.pathname - ) - - return _react.default.createElement( - _pageRenderer.default, - Object.assign( - { - location, - pageResources, - }, - pageResources.json - ) - ) -} - -ProdPageRenderer.propTypes = { - location: _propTypes.default.shape({ - pathname: _propTypes.default.string.isRequired, - }).isRequired, -} -var _default = ProdPageRenderer -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js b/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js deleted file mode 100644 index 8d56031..0000000 --- a/packages/gatsby-theme/.cache/commonjs/public-page-renderer.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' - -const preferDefault = m => (m && m.default) || m - -if (process.env.BUILD_STAGE === `develop`) { - module.exports = preferDefault(require(`./public-page-renderer-dev`)) -} else if (process.env.BUILD_STAGE === `build-javascript`) { - module.exports = preferDefault(require(`./public-page-renderer-prod`)) -} else { - module.exports = () => null -} diff --git a/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js b/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js deleted file mode 100644 index 6123b1d..0000000 --- a/packages/gatsby-theme/.cache/commonjs/react-lifecycles-compat.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' - -exports.polyfill = Component => Component diff --git a/packages/gatsby-theme/.cache/commonjs/register-service-worker.js b/packages/gatsby-theme/.cache/commonjs/register-service-worker.js deleted file mode 100644 index 4ef7430..0000000 --- a/packages/gatsby-theme/.cache/commonjs/register-service-worker.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict' - -var _apiRunnerBrowser = require('./api-runner-browser') - -if ( - window.location.protocol !== `https:` && - window.location.hostname !== `localhost` -) { - console.error( - `Service workers can only be used over HTTPS, or on localhost for development` - ) -} else if (`serviceWorker` in navigator) { - navigator.serviceWorker - .register(`${__PATH_PREFIX__}/sw.js`) - .then(function(reg) { - reg.addEventListener(`updatefound`, () => { - ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerUpdateFound`, { - serviceWorker: reg, - }) // The updatefound event implies that reg.installing is set; see - // https://w3c.github.io/ServiceWorker/#service-worker-registration-updatefound-event - - const installingWorker = reg.installing - console.log(`installingWorker`, installingWorker) - installingWorker.addEventListener(`statechange`, () => { - switch (installingWorker.state) { - case `installed`: - if (navigator.serviceWorker.controller) { - // At this point, the old content will have been purged and the fresh content will - // have been added to the cache. - // We set a flag so Gatsby Link knows to refresh the page on next navigation attempt - window.___swUpdated = true // We call the onServiceWorkerUpdateReady API so users can show update prompts. - - ;(0, _apiRunnerBrowser.apiRunner)( - `onServiceWorkerUpdateReady`, - { - serviceWorker: reg, - } - ) // If resources failed for the current page, reload. - - if (window.___failedResources) { - console.log(`resources failed, SW updated - reloading`) - window.location.reload() - } - } else { - // At this point, everything has been precached. - // It's the perfect time to display a "Content is cached for offline use." message. - console.log(`Content is now available offline!`) // Post to service worker that install is complete. - // Delay to allow time for the event listener to be added -- - // otherwise fetch is called too soon and resources aren't cached. - - ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerInstalled`, { - serviceWorker: reg, - }) - } - - break - - case `redundant`: - console.error(`The installing service worker became redundant.`) - ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerRedundant`, { - serviceWorker: reg, - }) - break - - case `activated`: - ;(0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerActive`, { - serviceWorker: reg, - }) - break - } - }) - }) - }) - .catch(function(e) { - console.error(`Error during service worker registration:`, e) - }) -} diff --git a/packages/gatsby-theme/.cache/commonjs/root.js b/packages/gatsby-theme/.cache/commonjs/root.js deleted file mode 100644 index 89c5342..0000000 --- a/packages/gatsby-theme/.cache/commonjs/root.js +++ /dev/null @@ -1,183 +0,0 @@ -'use strict' - -var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard') - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _extends2 = _interopRequireDefault( - require('@babel/runtime/helpers/extends') -) - -var _react = _interopRequireWildcard(require('react')) - -var _router = require('@reach/router') - -var _gatsbyReactRouterScroll = require('gatsby-react-router-scroll') - -var _navigation = require('./navigation') - -var _apiRunnerBrowser = require('./api-runner-browser') - -var _syncRequires = _interopRequireDefault(require('./sync-requires')) - -var _pages = _interopRequireDefault(require('./pages.json')) - -var _loader = _interopRequireDefault(require('./loader')) - -var _jsonStore = _interopRequireDefault(require('./json-store')) - -var _ensureResources = _interopRequireDefault(require('./ensure-resources')) - -var _errorOverlayHandler = require('./error-overlay-handler') - -if (window.__webpack_hot_middleware_reporter__ !== undefined) { - const overlayErrorID = `webpack` // Report build errors - - window.__webpack_hot_middleware_reporter__.useCustomOverlay({ - showProblems(type, obj) { - if (type !== `errors`) { - ;(0, _errorOverlayHandler.clearError)(overlayErrorID) - return - } - - ;(0, _errorOverlayHandler.reportError)(overlayErrorID, obj[0]) - }, - - clear() { - ;(0, _errorOverlayHandler.clearError)(overlayErrorID) - }, - }) -} - -;(0, _navigation.init)() - -class RouteHandler extends _react.default.Component { - render() { - let location = this.props.location // check if page exists - in dev pages are sync loaded, it's safe to use - // loader.getPage - - let page = _loader.default.getPage(location.pathname) - - if (page) { - return _react.default.createElement( - _ensureResources.default, - { - location: location, - }, - locationAndPageResources => - _react.default.createElement( - _navigation.RouteUpdates, - { - location: location, - }, - _react.default.createElement( - _gatsbyReactRouterScroll.ScrollContext, - { - location: location, - shouldUpdateScroll: _navigation.shouldUpdateScroll, - }, - _react.default.createElement( - _jsonStore.default, - (0, _extends2.default)( - { - pages: _pages.default, - }, - this.props, - locationAndPageResources - ) - ) - ) - ) - ) - } else { - const dev404Page = _pages.default.find(p => - /^\/dev-404-page\/?$/.test(p.path) - ) - - const Dev404Page = - _syncRequires.default.components[dev404Page.componentChunkName] - - if (!_loader.default.getPage(`/404.html`)) { - return _react.default.createElement( - _navigation.RouteUpdates, - { - location: location, - }, - _react.default.createElement( - Dev404Page, - (0, _extends2.default)( - { - pages: _pages.default, - }, - this.props - ) - ) - ) - } - - return _react.default.createElement( - _ensureResources.default, - { - location: location, - }, - locationAndPageResources => - _react.default.createElement( - _navigation.RouteUpdates, - { - location: location, - }, - _react.default.createElement( - Dev404Page, - (0, _extends2.default)( - { - pages: _pages.default, - custom404: _react.default.createElement( - _jsonStore.default, - (0, _extends2.default)( - { - pages: _pages.default, - }, - this.props, - locationAndPageResources - ) - ), - }, - this.props - ) - ) - ) - ) - } - } -} - -const Root = () => - (0, _react.createElement)( - _router.Router, - { - basepath: __PATH_PREFIX__, - }, - (0, _react.createElement)(RouteHandler, { - path: `/*`, - }) - ) // Let site, plugins wrap the site e.g. for Redux. - -const WrappedRoot = (0, _apiRunnerBrowser.apiRunner)( - `wrapRootElement`, - { - element: _react.default.createElement(Root, null), - }, - _react.default.createElement(Root, null), - ({ result, plugin }) => { - return { - element: result, - } - } -).pop() - -var _default = () => WrappedRoot - -exports.default = _default diff --git a/packages/gatsby-theme/.cache/commonjs/socketIo.js b/packages/gatsby-theme/.cache/commonjs/socketIo.js deleted file mode 100644 index 800c766..0000000 --- a/packages/gatsby-theme/.cache/commonjs/socketIo.js +++ /dev/null @@ -1,117 +0,0 @@ -'use strict' - -exports.__esModule = true -exports.default = socketIo -exports.getPageData = getPageData -exports.registerPath = registerPath -exports.unregisterPath = unregisterPath -exports.getIsInitialized = exports.getPageQueryData = exports.getStaticQueryData = void 0 - -var _errorOverlayHandler = require('./error-overlay-handler') - -let socket = null -let staticQueryData = {} -let pageQueryData = {} -let isInitialized = false - -const getStaticQueryData = () => staticQueryData - -exports.getStaticQueryData = getStaticQueryData - -const getPageQueryData = () => pageQueryData - -exports.getPageQueryData = getPageQueryData - -const getIsInitialized = () => isInitialized - -exports.getIsInitialized = getIsInitialized - -function socketIo() { - if (process.env.NODE_ENV !== `production`) { - if (!socket) { - // Try to initialize web socket if we didn't do it already - try { - // eslint-disable-next-line no-undef - socket = io() - - const didDataChange = (msg, queryData) => - !(msg.payload.id in queryData) || - JSON.stringify(msg.payload.result) !== - JSON.stringify(queryData[msg.payload.id]) - - socket.on(`message`, msg => { - if (msg.type === `staticQueryResult`) { - if (didDataChange(msg, staticQueryData)) { - staticQueryData = Object.assign({}, staticQueryData, { - [msg.payload.id]: msg.payload.result, - }) - } - } else if (msg.type === `pageQueryResult`) { - if (didDataChange(msg, pageQueryData)) { - pageQueryData = Object.assign({}, pageQueryData, { - [msg.payload.id]: msg.payload.result, - }) - } - } else if (msg.type === `overlayError`) { - if (msg.payload.message) { - ;(0, _errorOverlayHandler.reportError)( - msg.payload.id, - msg.payload.message - ) - } else { - ;(0, _errorOverlayHandler.clearError)(msg.payload.id) - } - } - - if (msg.type && msg.payload) { - ___emitter.emit(msg.type, msg.payload) - } - }) - } catch (err) { - console.error(`Could not connect to socket.io on dev server.`) - } - } - - return socket - } else { - return null - } -} - -const inFlightGetPageDataPromiseCache = {} - -function getPageData(pathname) { - if (inFlightGetPageDataPromiseCache[pathname]) { - return inFlightGetPageDataPromiseCache[pathname] - } else { - inFlightGetPageDataPromiseCache[pathname] = new Promise(resolve => { - if (pageQueryData[pathname]) { - delete inFlightGetPageDataPromiseCache[pathname] - resolve(pageQueryData[pathname]) - } else { - const onPageDataCallback = msg => { - if (msg.type === `pageQueryResult` && msg.payload.id === pathname) { - socket.off(`message`, onPageDataCallback) - delete inFlightGetPageDataPromiseCache[pathname] - resolve(pageQueryData[pathname]) - } - } - - socket.on(`message`, onPageDataCallback) - socket.emit(`getDataForPath`, pathname) - } - }) - } - - return inFlightGetPageDataPromiseCache[pathname] -} // Tell websocket-manager.js the new path we're on. -// This will help the backend prioritize queries for this -// path. - -function registerPath(path) { - socket.emit(`registerPath`, path) -} // Unregister the former path - -function unregisterPath(path) { - socket.emit(`unregisterPath`, path) -} diff --git a/packages/gatsby-theme/.cache/commonjs/static-entry.js b/packages/gatsby-theme/.cache/commonjs/static-entry.js deleted file mode 100644 index 3878bdd..0000000 --- a/packages/gatsby-theme/.cache/commonjs/static-entry.js +++ /dev/null @@ -1,448 +0,0 @@ -'use strict' - -var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault') - -exports.__esModule = true -exports.default = void 0 - -var _extends2 = _interopRequireDefault( - require('@babel/runtime/helpers/extends') -) - -const React = require(`react`) - -const fs = require(`fs`) - -const _require = require(`path`), - join = _require.join - -const _require2 = require(`react-dom/server`), - renderToString = _require2.renderToString, - renderToStaticMarkup = _require2.renderToStaticMarkup - -const _require3 = require(`@reach/router`), - ServerLocation = _require3.ServerLocation, - Router = _require3.Router, - isRedirect = _require3.isRedirect - -const _require4 = require(`lodash`), - get = _require4.get, - merge = _require4.merge, - isObject = _require4.isObject, - flatten = _require4.flatten, - uniqBy = _require4.uniqBy - -const apiRunner = require(`./api-runner-ssr`) - -const syncRequires = require(`./sync-requires`) - -const _require5 = require(`./data.json`), - dataPaths = _require5.dataPaths, - pages = _require5.pages - -const _require6 = require(`gatsby/package.json`), - gatsbyVersion = _require6.version // Speed up looking up pages. - -const pagesObjectMap = new Map() -pages.forEach(p => pagesObjectMap.set(p.path, p)) -const stats = JSON.parse( - fs.readFileSync(`${process.cwd()}/public/webpack.stats.json`, `utf-8`) -) -const chunkMapping = JSON.parse( - fs.readFileSync(`${process.cwd()}/public/chunk-map.json`, `utf-8`) -) // const testRequireError = require("./test-require-error") -// For some extremely mysterious reason, webpack adds the above module *after* -// this module so that when this code runs, testRequireError is undefined. -// So in the meantime, we'll just inline it. - -const testRequireError = (moduleName, err) => { - const regex = new RegExp(`Error: Cannot find module\\s.${moduleName}`) - const firstLine = err.toString().split(`\n`)[0] - return regex.test(firstLine) -} - -let Html - -try { - Html = require(`../src/html`) -} catch (err) { - if (testRequireError(`../src/html`, err)) { - Html = require(`./default-html`) - } else { - throw err - } -} - -Html = Html && Html.__esModule ? Html.default : Html - -const getPage = path => pagesObjectMap.get(path) - -const createElement = React.createElement - -const sanitizeComponents = components => { - if (Array.isArray(components)) { - // remove falsy items - return components.filter(val => (Array.isArray(val) ? val.length > 0 : val)) - } else { - // we also accept single components, so we need to handle this case as well - return components ? [components] : [] - } -} - -var _default = (pagePath, callback) => { - let bodyHtml = `` - let headComponents = [ - React.createElement('meta', { - name: 'generator', - content: `Gatsby ${gatsbyVersion}`, - key: `generator-${gatsbyVersion}`, - }), - ] - let htmlAttributes = {} - let bodyAttributes = {} - let preBodyComponents = [] - let postBodyComponents = [] - let bodyProps = {} - - const replaceBodyHTMLString = body => { - bodyHtml = body - } - - const setHeadComponents = components => { - headComponents = headComponents.concat(sanitizeComponents(components)) - } - - const setHtmlAttributes = attributes => { - htmlAttributes = merge(htmlAttributes, attributes) - } - - const setBodyAttributes = attributes => { - bodyAttributes = merge(bodyAttributes, attributes) - } - - const setPreBodyComponents = components => { - preBodyComponents = preBodyComponents.concat(sanitizeComponents(components)) - } - - const setPostBodyComponents = components => { - postBodyComponents = postBodyComponents.concat( - sanitizeComponents(components) - ) - } - - const setBodyProps = props => { - bodyProps = merge({}, bodyProps, props) - } - - const getHeadComponents = () => headComponents - - const replaceHeadComponents = components => { - headComponents = sanitizeComponents(components) - } - - const getPreBodyComponents = () => preBodyComponents - - const replacePreBodyComponents = components => { - preBodyComponents = sanitizeComponents(components) - } - - const getPostBodyComponents = () => postBodyComponents - - const replacePostBodyComponents = components => { - postBodyComponents = sanitizeComponents(components) - } - - const page = getPage(pagePath) - let dataAndContext = {} - - if (page.jsonName in dataPaths) { - const pathToJsonData = join( - process.cwd(), - `/public/static/d`, - `${dataPaths[page.jsonName]}.json` - ) - - try { - dataAndContext = JSON.parse(fs.readFileSync(pathToJsonData)) - } catch (e) { - console.log(`error`, pathToJsonData, e) - process.exit() - } - } - - class RouteHandler extends React.Component { - render() { - const props = Object.assign({}, this.props, dataAndContext, { - pathContext: dataAndContext.pageContext, - }) - const pageElement = createElement( - syncRequires.components[page.componentChunkName], - props - ) - const wrappedPage = apiRunner( - `wrapPageElement`, - { - element: pageElement, - props, - }, - pageElement, - ({ result }) => { - return { - element: result, - props, - } - } - ).pop() - return wrappedPage - } - } - - const routerElement = createElement( - ServerLocation, - { - url: `${__PATH_PREFIX__}${pagePath}`, - }, - createElement( - Router, - { - baseuri: `${__PATH_PREFIX__}`, - }, - createElement(RouteHandler, { - path: `/*`, - }) - ) - ) - const bodyComponent = apiRunner( - `wrapRootElement`, - { - element: routerElement, - pathname: pagePath, - }, - routerElement, - ({ result }) => { - return { - element: result, - pathname: pagePath, - } - } - ).pop() // Let the site or plugin render the page component. - - apiRunner(`replaceRenderer`, { - bodyComponent, - replaceBodyHTMLString, - setHeadComponents, - setHtmlAttributes, - setBodyAttributes, - setPreBodyComponents, - setPostBodyComponents, - setBodyProps, - pathname: pagePath, - pathPrefix: __PATH_PREFIX__, - }) // If no one stepped up, we'll handle it. - - if (!bodyHtml) { - try { - bodyHtml = renderToString(bodyComponent) - } catch (e) { - // ignore @reach/router redirect errors - if (!isRedirect(e)) throw e - } - } // Create paths to scripts - - let scriptsAndStyles = flatten( - [`app`, page.componentChunkName].map(s => { - const fetchKey = `assetsByChunkName[${s}]` - let chunks = get(stats, fetchKey) - let namedChunkGroups = get(stats, `namedChunkGroups`) - - if (!chunks) { - return null - } - - chunks = chunks.map(chunk => { - if (chunk === `/`) { - return null - } - - return { - rel: `preload`, - name: chunk, - } - }) - namedChunkGroups[s].assets.forEach(asset => - chunks.push({ - rel: `preload`, - name: asset, - }) - ) - const childAssets = namedChunkGroups[s].childAssets - - for (const rel in childAssets) { - chunks = merge( - chunks, - childAssets[rel].map(chunk => { - return { - rel, - name: chunk, - } - }) - ) - } - - return chunks - }) - ) - .filter(s => isObject(s)) - .sort((s1, s2) => (s1.rel == `preload` ? -1 : 1)) // given priority to preload - - scriptsAndStyles = uniqBy(scriptsAndStyles, item => item.name) - const scripts = scriptsAndStyles.filter( - script => script.name && script.name.endsWith(`.js`) - ) - const styles = scriptsAndStyles.filter( - style => style.name && style.name.endsWith(`.css`) - ) - apiRunner(`onRenderBody`, { - setHeadComponents, - setHtmlAttributes, - setBodyAttributes, - setPreBodyComponents, - setPostBodyComponents, - setBodyProps, - pathname: pagePath, - bodyHtml, - scripts, - styles, - pathPrefix: __PATH_PREFIX__, - }) - scripts - .slice(0) - .reverse() - .forEach(script => { - // Add preload/prefetch s for scripts. - headComponents.push( - React.createElement('link', { - as: 'script', - rel: script.rel, - key: script.name, - href: `${__PATH_PREFIX__}/${script.name}`, - }) - ) - }) - - if (page.jsonName in dataPaths) { - const dataPath = `${__PATH_PREFIX__}/static/d/${ - dataPaths[page.jsonName] - }.json` - headComponents.push( - React.createElement('link', { - as: 'fetch', - rel: 'preload', - key: dataPath, - href: dataPath, - crossOrigin: 'use-credentials', - }) - ) - } - - styles - .slice(0) - .reverse() - .forEach(style => { - // Add s for styles that should be prefetched - // otherwise, inline as a