gatsby-link 5.4.0-next.1 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [5.3.1](https://github.com/gatsbyjs/gatsby/commits/gatsby-link@5.3.1/packages/gatsby-link) (2022-12-14)
7
+
8
+ **Note:** Version bump only for package gatsby-link
9
+
10
+ ## [5.3.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-link@5.3.0/packages/gatsby-link) (2022-12-13)
11
+
12
+ [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v5.3)
13
+
14
+ #### Chores
15
+
16
+ - update dependency prepend-directive to ^1.1.0 for gatsby-link [#37189](https://github.com/gatsbyjs/gatsby/issues/37189) ([80b9473](https://github.com/gatsbyjs/gatsby/commit/80b947339cca93b5ecb8ee7b5b44b5c43be67de0))
17
+ - Bump @gatsbyjs/reach-router to v2.0.0 [#37121](https://github.com/gatsbyjs/gatsby/issues/37121) ([aa5808b](https://github.com/gatsbyjs/gatsby/commit/aa5808becb16c4d98953082a7e04b6b7d40cd9a5))
18
+
6
19
  ## [5.2.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-link@5.2.0/packages/gatsby-link) (2022-11-25)
7
20
 
8
21
  [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v5.2)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/parse-path.js","../src/is-local-link.js","../src/prefix-helpers.js","../src/rewrite-link-path.js","../src/index.js"],"sourcesContent":["export function parsePath(path) {\n let pathname = path || `/`\n let search = ``\n let hash = ``\n\n const hashIndex = pathname.indexOf(`#`)\n if (hashIndex !== -1) {\n hash = pathname.slice(hashIndex)\n pathname = pathname.slice(0, hashIndex)\n }\n\n const searchIndex = pathname.indexOf(`?`)\n if (searchIndex !== -1) {\n search = pathname.slice(searchIndex)\n pathname = pathname.slice(0, searchIndex)\n }\n\n return {\n pathname: pathname,\n search: search === `?` ? `` : search,\n hash: hash === `#` ? `` : hash,\n }\n}\n","// Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js\nconst ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\\d+\\-.]*?:/\nconst isAbsolute = path => ABSOLUTE_URL_REGEX.test(path)\n\nexport const isLocalLink = path => {\n if (typeof path !== `string`) {\n return undefined\n // TODO(v5): Re-Add TypeError\n // throw new TypeError(`Expected a \\`string\\`, got \\`${typeof path}\\``)\n }\n\n return !isAbsolute(path)\n}\n","import { isLocalLink } from \"./is-local-link\"\n\nexport const getGlobalBasePrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __BASE_PATH__ !== `undefined`\n ? __BASE_PATH__\n : undefined\n : __BASE_PATH__\n\n// These global values are wrapped in typeof clauses to ensure the values exist.\n// This is especially problematic in unit testing of this component.\nexport const getGlobalPathPrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __PATH_PREFIX__ !== `undefined`\n ? __PATH_PREFIX__\n : undefined\n : __PATH_PREFIX__\n\nexport function withPrefix(path, prefix = getGlobalBasePrefix()) {\n if (!isLocalLink(path)) {\n return path\n }\n\n if (path.startsWith(`./`) || path.startsWith(`../`)) {\n return path\n }\n const base = prefix ?? getGlobalPathPrefix() ?? `/`\n\n return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${\n path.startsWith(`/`) ? path : `/${path}`\n }`\n}\n","import { resolve } from \"@gatsbyjs/reach-router\"\n// Specific import to treeshake Node.js stuff\nimport { applyTrailingSlashOption } from \"gatsby-page-utils/apply-trailing-slash-option\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { withPrefix } from \"./prefix-helpers\"\n\nconst isAbsolutePath = path => path?.startsWith(`/`)\n\nconst getGlobalTrailingSlash = () =>\n typeof __TRAILING_SLASH__ !== `undefined` ? __TRAILING_SLASH__ : undefined\n\nfunction applyTrailingSlashOptionOnPathnameOnly(path, option) {\n const { pathname, search, hash } = parsePath(path)\n const output = applyTrailingSlashOption(pathname, option)\n\n return `${output}${search}${hash}`\n}\n\nfunction absolutify(path, current) {\n // If it's already absolute, return as-is\n if (isAbsolutePath(path)) {\n return path\n }\n\n const option = getGlobalTrailingSlash()\n const absolutePath = resolve(path, current)\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(absolutePath, option)\n }\n\n return absolutePath\n}\n\nfunction applyPrefix(path) {\n const prefixed = withPrefix(path)\n const option = getGlobalTrailingSlash()\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(prefixed, option)\n }\n\n return prefixed\n}\n\nexport const rewriteLinkPath = (path, relativeTo) => {\n if (typeof path === `number`) {\n return path\n }\n if (!isLocalLink(path)) {\n return path\n }\n\n return isAbsolutePath(path) ? applyPrefix(path) : absolutify(path, relativeTo)\n}\n","import PropTypes from \"prop-types\"\nimport React from \"react\"\nimport { Link as ReachRouterLink, Location } from \"@gatsbyjs/reach-router\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { rewriteLinkPath } from \"./rewrite-link-path\"\nimport { withPrefix, getGlobalPathPrefix } from \"./prefix-helpers\"\n\nexport { parsePath, withPrefix }\n\nexport function withAssetPrefix(path) {\n return withPrefix(path, getGlobalPathPrefix())\n}\n\nconst NavLinkPropTypes = {\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n partiallyActive: PropTypes.bool,\n}\n\n// Set up IntersectionObserver\nconst createIntersectionObserver = (el, cb) => {\n const io = new window.IntersectionObserver(entries => {\n entries.forEach(entry => {\n if (el === entry.target) {\n // Check if element is within viewport, remove listener, destroy observer, and run link callback.\n // MSEdge doesn't currently support isIntersecting, so also test for an intersectionRatio > 0\n cb(entry.isIntersecting || entry.intersectionRatio > 0)\n }\n })\n })\n\n // Add element to the observer\n io.observe(el)\n\n return { instance: io, el }\n}\n\nfunction GatsbyLinkLocationWrapper(props) {\n return (\n <Location>\n {({ location }) => <GatsbyLink {...props} _location={location} />}\n </Location>\n )\n}\n\nclass GatsbyLink extends React.Component {\n constructor(props) {\n super(props)\n // Default to no support for IntersectionObserver\n let IOSupported = false\n if (typeof window !== `undefined` && window.IntersectionObserver) {\n IOSupported = true\n }\n\n this.state = {\n IOSupported,\n }\n this.abortPrefetch = null\n this.handleRef = this.handleRef.bind(this)\n }\n\n _prefetch() {\n let currentPath = window.location.pathname + window.location.search\n\n // reach router should have the correct state\n if (this.props._location && this.props._location.pathname) {\n currentPath = this.props._location.pathname + this.props._location.search\n }\n\n const rewrittenPath = rewriteLinkPath(this.props.to, currentPath)\n const parsed = parsePath(rewrittenPath)\n\n const newPathName = parsed.pathname + parsed.search\n\n // Prefetch is used to speed up next navigations. When you use it on the current navigation,\n // there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete\n if (currentPath !== newPathName) {\n return ___loader.enqueue(newPathName)\n }\n\n return undefined\n }\n\n componentWillUnmount() {\n if (!this.io) {\n return\n }\n const { instance, el } = this.io\n\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n\n instance.unobserve(el)\n instance.disconnect()\n }\n\n handleRef(ref) {\n if (\n this.props.innerRef &&\n Object.prototype.hasOwnProperty.call(this.props.innerRef, `current`)\n ) {\n this.props.innerRef.current = ref\n } else if (this.props.innerRef) {\n this.props.innerRef(ref)\n }\n\n if (this.state.IOSupported && ref) {\n // If IO supported and element reference found, setup Observer functionality\n this.io = createIntersectionObserver(ref, inViewPort => {\n if (inViewPort) {\n this.abortPrefetch = this._prefetch()\n } else {\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n }\n })\n }\n }\n\n defaultGetProps = ({ isPartiallyCurrent, isCurrent }) => {\n if (this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {\n return {\n className: [this.props.className, this.props.activeClassName]\n .filter(Boolean)\n .join(` `),\n style: { ...this.props.style, ...this.props.activeStyle },\n }\n }\n return null\n }\n\n render() {\n const {\n to,\n getProps = this.defaultGetProps,\n onClick,\n onMouseEnter,\n /* eslint-disable no-unused-vars */\n activeClassName: $activeClassName,\n activeStyle: $activeStyle,\n innerRef: $innerRef,\n partiallyActive,\n state,\n replace,\n _location,\n /* eslint-enable no-unused-vars */\n ...rest\n } = this.props\n\n if (process.env.NODE_ENV !== `production` && !isLocalLink(to)) {\n console.warn(\n `External link ${to} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`\n )\n }\n\n const prefixedTo = rewriteLinkPath(to, _location.pathname)\n if (!isLocalLink(prefixedTo)) {\n return <a href={prefixedTo} {...rest} />\n }\n\n return (\n <ReachRouterLink\n to={prefixedTo}\n state={state}\n getProps={getProps}\n innerRef={this.handleRef}\n onMouseEnter={e => {\n if (onMouseEnter) {\n onMouseEnter(e)\n }\n const parsed = parsePath(prefixedTo)\n ___loader.hovering(parsed.pathname + parsed.search)\n }}\n onClick={e => {\n if (onClick) {\n onClick(e)\n }\n\n if (\n e.button === 0 && // ignore right clicks\n !this.props.target && // let browser handle \"target=_blank\"\n !e.defaultPrevented && // onClick prevented default\n !e.metaKey && // ignore clicks with modifier keys...\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey\n ) {\n e.preventDefault()\n\n let shouldReplace = replace\n const isCurrent = encodeURI(prefixedTo) === _location.pathname\n\n if (typeof replace !== `boolean` && isCurrent) {\n shouldReplace = true\n }\n // Make sure the necessary scripts and data are\n // loaded before continuing.\n window.___navigate(prefixedTo, {\n state,\n replace: shouldReplace,\n })\n }\n\n return true\n }}\n {...rest}\n />\n )\n }\n}\n\nGatsbyLink.propTypes = {\n ...NavLinkPropTypes,\n onClick: PropTypes.func,\n to: PropTypes.string.isRequired,\n replace: PropTypes.bool,\n state: PropTypes.object,\n}\n\nexport const Link = React.forwardRef((props, ref) => (\n <GatsbyLinkLocationWrapper innerRef={ref} {...props} />\n))\n\nexport const navigate = (to, options) => {\n window.___navigate(rewriteLinkPath(to, window.location.pathname), options)\n}\n"],"names":["path","pathname","indexOf","hashIndex","hash","slice","searchIndex","search","test","isAbsolute","env","NODE_ENV","__PATH_PREFIX__","undefined","prefix","__BASE_PATH__","isLocalLink","startsWith","getGlobalPathPrefix","base","endsWith","__TRAILING_SLASH__","option","parsePath","applyTrailingSlashOption","relativeTo","withPrefix","getGlobalTrailingSlash","prefixed","applyPrefix","current","isAbsolutePath","resolve","absolutePath","absolutify","activeClassName","PropTypes","string","activeStyle","object","partiallyActive","bool","props","React","Location","GatsbyLink","_location","location","_this","defaultGetProps","isPartiallyCurrent","isCurrent","className","filter","Boolean","join","style","window","IntersectionObserver","IOSupported","state","abortPrefetch","handleRef","bind","_prefetch","this","currentPath","rewriteLinkPath","to","parsed","newPathName","enqueue","componentWillUnmount","io","instance","el","abort","unobserve","disconnect","ref","cb","innerRef","Object","prototype","hasOwnProperty","call","inViewPort","_this2","entries","forEach","entry","target","isIntersecting","intersectionRatio","observe","render","getProps","onClick","onMouseEnter","replace","rest","process","console","warn","prefixedTo","ReachRouterLink","e","___loader","hovering","button","_this3","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","preventDefault","encodeURI","shouldReplace","___navigate","href","Component","propTypes","NavLinkPropTypes","func","isRequired","Link","forwardRef","GatsbyLinkLocationWrapper","options"],"mappings":"0mBAA0BA,GACxB,MAAeA,mBAIGC,EAASC,cACR,IAAfC,IACFC,EAAOH,EAASI,MAAMF,GACtBF,EAAWA,EAASI,MAAM,EAAGF,IAG/B,MAAoBF,EAASC,aAM7B,OALqB,IAAjBI,IACFC,EAASN,EAASI,MAAMC,GACxBL,EAAWA,EAASI,MAAM,EAAGC,IAGxB,CACLL,SAAUA,EACVM,aAAQA,KAAsBA,EAC9BH,WAAMA,KAAoBA,GCnB9B,MAA2B,+BAGA,SAAAJ,G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AMkB"}
1
+ {"version":3,"file":"index.js","sources":["../src/parse-path.js","../src/is-local-link.js","../src/prefix-helpers.js","../src/rewrite-link-path.js","../src/index.js"],"sourcesContent":["export function parsePath(path) {\n let pathname = path || `/`\n let search = ``\n let hash = ``\n\n const hashIndex = pathname.indexOf(`#`)\n if (hashIndex !== -1) {\n hash = pathname.slice(hashIndex)\n pathname = pathname.slice(0, hashIndex)\n }\n\n const searchIndex = pathname.indexOf(`?`)\n if (searchIndex !== -1) {\n search = pathname.slice(searchIndex)\n pathname = pathname.slice(0, searchIndex)\n }\n\n return {\n pathname: pathname,\n search: search === `?` ? `` : search,\n hash: hash === `#` ? `` : hash,\n }\n}\n","// Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js\nconst ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\\d+\\-.]*?:/\nconst isAbsolute = path => ABSOLUTE_URL_REGEX.test(path)\n\nexport const isLocalLink = path => {\n if (typeof path !== `string`) {\n return undefined\n // TODO(v5): Re-Add TypeError\n // throw new TypeError(`Expected a \\`string\\`, got \\`${typeof path}\\``)\n }\n\n return !isAbsolute(path)\n}\n","import { isLocalLink } from \"./is-local-link\"\n\nexport const getGlobalBasePrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __BASE_PATH__ !== `undefined`\n ? __BASE_PATH__\n : undefined\n : __BASE_PATH__\n\n// These global values are wrapped in typeof clauses to ensure the values exist.\n// This is especially problematic in unit testing of this component.\nexport const getGlobalPathPrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __PATH_PREFIX__ !== `undefined`\n ? __PATH_PREFIX__\n : undefined\n : __PATH_PREFIX__\n\nexport function withPrefix(path, prefix = getGlobalBasePrefix()) {\n if (!isLocalLink(path)) {\n return path\n }\n\n if (path.startsWith(`./`) || path.startsWith(`../`)) {\n return path\n }\n const base = prefix ?? getGlobalPathPrefix() ?? `/`\n\n return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${\n path.startsWith(`/`) ? path : `/${path}`\n }`\n}\n","import { resolve } from \"@gatsbyjs/reach-router\"\n// Specific import to treeshake Node.js stuff\nimport { applyTrailingSlashOption } from \"gatsby-page-utils/apply-trailing-slash-option\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { withPrefix } from \"./prefix-helpers\"\n\nconst isAbsolutePath = path => path?.startsWith(`/`)\n\nconst getGlobalTrailingSlash = () =>\n typeof __TRAILING_SLASH__ !== `undefined` ? __TRAILING_SLASH__ : undefined\n\nfunction applyTrailingSlashOptionOnPathnameOnly(path, option) {\n const { pathname, search, hash } = parsePath(path)\n const output = applyTrailingSlashOption(pathname, option)\n\n return `${output}${search}${hash}`\n}\n\nfunction absolutify(path, current) {\n // If it's already absolute, return as-is\n if (isAbsolutePath(path)) {\n return path\n }\n\n const option = getGlobalTrailingSlash()\n const absolutePath = resolve(path, current)\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(absolutePath, option)\n }\n\n return absolutePath\n}\n\nfunction applyPrefix(path) {\n const prefixed = withPrefix(path)\n const option = getGlobalTrailingSlash()\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(prefixed, option)\n }\n\n return prefixed\n}\n\nexport const rewriteLinkPath = (path, relativeTo) => {\n if (typeof path === `number`) {\n return path\n }\n if (!isLocalLink(path)) {\n return path\n }\n\n return isAbsolutePath(path) ? applyPrefix(path) : absolutify(path, relativeTo)\n}\n","import PropTypes from \"prop-types\"\nimport React from \"react\"\nimport { Link as ReachRouterLink, Location } from \"@gatsbyjs/reach-router\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { rewriteLinkPath } from \"./rewrite-link-path\"\nimport { withPrefix, getGlobalPathPrefix } from \"./prefix-helpers\"\n\nexport { parsePath, withPrefix }\n\nexport function withAssetPrefix(path) {\n return withPrefix(path, getGlobalPathPrefix())\n}\n\nconst NavLinkPropTypes = {\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n partiallyActive: PropTypes.bool,\n}\n\n// Set up IntersectionObserver\nconst createIntersectionObserver = (el, cb) => {\n const io = new window.IntersectionObserver(entries => {\n entries.forEach(entry => {\n if (el === entry.target) {\n // Check if element is within viewport, remove listener, destroy observer, and run link callback.\n // MSEdge doesn't currently support isIntersecting, so also test for an intersectionRatio > 0\n cb(entry.isIntersecting || entry.intersectionRatio > 0)\n }\n })\n })\n\n // Add element to the observer\n io.observe(el)\n\n return { instance: io, el }\n}\n\nfunction GatsbyLinkLocationWrapper(props) {\n return (\n <Location>\n {({ location }) => <GatsbyLink {...props} _location={location} />}\n </Location>\n )\n}\n\nclass GatsbyLink extends React.Component {\n constructor(props) {\n super(props)\n // Default to no support for IntersectionObserver\n let IOSupported = false\n if (typeof window !== `undefined` && window.IntersectionObserver) {\n IOSupported = true\n }\n\n this.state = {\n IOSupported,\n }\n this.abortPrefetch = null\n this.handleRef = this.handleRef.bind(this)\n }\n\n _prefetch() {\n let currentPath = window.location.pathname + window.location.search\n\n // reach router should have the correct state\n if (this.props._location && this.props._location.pathname) {\n currentPath = this.props._location.pathname + this.props._location.search\n }\n\n const rewrittenPath = rewriteLinkPath(this.props.to, currentPath)\n const parsed = parsePath(rewrittenPath)\n\n const newPathName = parsed.pathname + parsed.search\n\n // Prefetch is used to speed up next navigations. When you use it on the current navigation,\n // there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete\n if (currentPath !== newPathName) {\n return ___loader.enqueue(newPathName)\n }\n\n return undefined\n }\n\n componentWillUnmount() {\n if (!this.io) {\n return\n }\n const { instance, el } = this.io\n\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n\n instance.unobserve(el)\n instance.disconnect()\n }\n\n handleRef(ref) {\n if (\n this.props.innerRef &&\n Object.prototype.hasOwnProperty.call(this.props.innerRef, `current`)\n ) {\n this.props.innerRef.current = ref\n } else if (this.props.innerRef) {\n this.props.innerRef(ref)\n }\n\n if (this.state.IOSupported && ref) {\n // If IO supported and element reference found, setup Observer functionality\n this.io = createIntersectionObserver(ref, inViewPort => {\n if (inViewPort) {\n this.abortPrefetch = this._prefetch()\n } else {\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n }\n })\n }\n }\n\n defaultGetProps = ({ isPartiallyCurrent, isCurrent }) => {\n if (this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {\n return {\n className: [this.props.className, this.props.activeClassName]\n .filter(Boolean)\n .join(` `),\n style: { ...this.props.style, ...this.props.activeStyle },\n }\n }\n return null\n }\n\n render() {\n const {\n to,\n getProps = this.defaultGetProps,\n onClick,\n onMouseEnter,\n /* eslint-disable no-unused-vars */\n activeClassName: $activeClassName,\n activeStyle: $activeStyle,\n innerRef: $innerRef,\n partiallyActive,\n state,\n replace,\n _location,\n /* eslint-enable no-unused-vars */\n ...rest\n } = this.props\n\n if (process.env.NODE_ENV !== `production` && !isLocalLink(to)) {\n console.warn(\n `External link ${to} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`\n )\n }\n\n const prefixedTo = rewriteLinkPath(to, _location.pathname)\n if (!isLocalLink(prefixedTo)) {\n return <a href={prefixedTo} {...rest} />\n }\n\n return (\n <ReachRouterLink\n to={prefixedTo}\n state={state}\n getProps={getProps}\n innerRef={this.handleRef}\n onMouseEnter={e => {\n if (onMouseEnter) {\n onMouseEnter(e)\n }\n const parsed = parsePath(prefixedTo)\n ___loader.hovering(parsed.pathname + parsed.search)\n }}\n onClick={e => {\n if (onClick) {\n onClick(e)\n }\n\n if (\n e.button === 0 && // ignore right clicks\n !this.props.target && // let browser handle \"target=_blank\"\n !e.defaultPrevented && // onClick prevented default\n !e.metaKey && // ignore clicks with modifier keys...\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey\n ) {\n e.preventDefault()\n\n let shouldReplace = replace\n const isCurrent = encodeURI(prefixedTo) === _location.pathname\n\n if (typeof replace !== `boolean` && isCurrent) {\n shouldReplace = true\n }\n // Make sure the necessary scripts and data are\n // loaded before continuing.\n window.___navigate(prefixedTo, {\n state,\n replace: shouldReplace,\n })\n }\n\n return true\n }}\n {...rest}\n />\n )\n }\n}\n\nGatsbyLink.propTypes = {\n ...NavLinkPropTypes,\n onClick: PropTypes.func,\n to: PropTypes.string.isRequired,\n replace: PropTypes.bool,\n state: PropTypes.object,\n}\n\nexport const Link = React.forwardRef((props, ref) => (\n <GatsbyLinkLocationWrapper innerRef={ref} {...props} />\n))\n\nexport const navigate = (to, options) => {\n window.___navigate(rewriteLinkPath(to, window.location.pathname), options)\n}\n"],"names":["parsePath","path","pathname","search","hash","hashIndex","indexOf","slice","searchIndex","ABSOLUTE_URL_REGEX","isLocalLink","test","isAbsolute","getGlobalPathPrefix","process","env","NODE_ENV","__PATH_PREFIX__","undefined","withPrefix","prefix","__BASE_PATH__","startsWith","base","_prefix","_ref","endsWith","isAbsolutePath","getGlobalTrailingSlash","__TRAILING_SLASH__","applyTrailingSlashOptionOnPathnameOnly","option","_parsePath","output","applyTrailingSlashOption","rewriteLinkPath","relativeTo","prefixed","applyPrefix","current","absolutePath","resolve","absolutify","NavLinkPropTypes","activeClassName","PropTypes","string","activeStyle","object","partiallyActive","bool","props","React","createElement","Location","location","GatsbyLink","_location","_React$Component","_this","call","this","defaultGetProps","_ref2","isPartiallyCurrent","isCurrent","className","filter","Boolean","join","style","_extends","IOSupported","window","IntersectionObserver","state","abortPrefetch","handleRef","bind","_assertThisInitialized","_proto","prototype","_prefetch","currentPath","parsed","to","newPathName","enqueue","componentWillUnmount","io","_this$io","instance","el","abort","unobserve","disconnect","ref","cb","_this2","innerRef","Object","hasOwnProperty","inViewPort","entries","forEach","entry","target","isIntersecting","intersectionRatio","observe","render","_this$props","getProps","_this$props$getProps","onClick","onMouseEnter","replace","rest","_objectWithoutPropertiesLoose","_excluded","console","warn","prefixedTo","ReachRouterLink","e","___loader","hovering","button","_this3","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","preventDefault","shouldReplace","encodeURI","___navigate","href","Component","propTypes","func","isRequired","Link","forwardRef","GatsbyLinkLocationWrapper","options"],"mappings":"+lBAAO,SAAkBA,EAACC,GACxB,IAAIC,EAAWD,GAAW,IAChBE,EAAA,GACFC,EAAA,GAEFC,EAAYH,EAASI,cACR,IAAfD,IACFD,EAAOF,EAASK,MAAMF,GACtBH,EAAWA,EAASK,MAAM,EAAGF,IAG/B,IAAMG,EAAcN,EAASI,aAM7B,OALqB,IAAjBE,IACFL,EAASD,EAASK,MAAMC,GACxBN,EAAWA,EAASK,MAAM,EAAGC,IAGxB,CACLN,SAAUA,EACVC,OAAsB,MAAdA,EAAc,GAAQA,EAC9BC,KAAU,MAAJA,EAAoBA,GAAAA,EAE9B,CCrBA,IAAMK,EAAqB,6BAGdC,EAAc,SAAAT,GACzB,GAA4B,mBAM5B,OATiB,SAAAA,GAAQQ,OAAAA,EAAmBE,KAAKV,EAAK,CAS9CW,CAAWX,EACrB,ECDaY,EAAsB,WAAH,MACV,eAAbC,QAACC,IAAIC,SACc,oBAAAC,gBACpBA,qBACAC,EACFD,eAAe,EAEd,SAAmBE,EAAClB,EAAMmB,GAAAA,IAAAA,EAAAA,EAC/B,YAD+BA,IAAAA,EAfM,eAArCN,QAAQC,IAAIC,SAC4B,oBAA7BK,cACLA,mBACAH,EACFG,gBAYCX,EAAYT,GACf,OACFA,EAEA,GAAIA,EAAKqB,WAAU,OAAUrB,EAAKqB,WAAiB,OACjD,OACFrB,EACA,IAAMsB,EAA6C,SAAhC,SAANH,GAAMI,EAAIX,KAA4BY,EAAA,IAEnD,MAAUF,IAAAA,MAAAA,GAAAA,EAAMG,SAAa,KAAGH,EAAKhB,MAAM,GAAI,GAAKgB,IAClDtB,EAAKqB,WAAe,KAAGrB,EAAI,IAAOA,EAEtC,CCxBA,IAAM0B,EAAiB,SAAA1B,GAAQA,OAAAA,MAAAA,OAAAA,EAAAA,EAAMqB,WAAe,IAAA,EAE9CM,EA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,KAAgBjE,EAAUvD,SAEpC,kBAAAkH,GAAkBnD,IAClCsE,GAAgB,GAIlB9D,OAAOgE,YAAYf,EAAY,CAC7B/C,MAAAA,EACAyC,QAASmB,GAEb,CAEA,OACF,CAAA,GACIlB,iBAhDCjE,EAAA,QAAAC,cAAA,IAAAkB,EAAA,CAAGmE,KAAMhB,GAAgBL,GAmDpC,EArKuBjE,CAAAA,CAAT,CAASA,EAAAA,QAAMuF,WAwK/BnF,EAAWoF,UAASrE,EAAA,CAAA,EACf5B,EAAgB,CACnBuE,QAASrE,EAAS,QAACgG,KACnBxD,GAAIxC,UAAUC,OAAOgG,WACrB1B,QAASvE,EAAAA,QAAUK,KACnByB,MAAO9B,EAAS,QAACG,SAGN+F,IAAAA,EAAO3F,EAAAA,QAAM4F,WAAW,SAAC7F,EAAO6C,gBAC3C,OAAA5C,EAAAA,QAAAC,cAAC4F,EAAyB1E,EAAA,CAAC4B,SAAUH,GAAS7C,GAAS,mCAGjC,SAACkC,EAAI6D,GAC3BzE,OAAOgE,YAAYtG,EAAgBkD,EAAIZ,OAAOlB,SAASrD,UAAWgJ,EACpE,8CA1NO,SAAyBjJ,GAC9B,OAAiBkB,EAAClB,EAAMY,IAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.mjs","sources":["../src/parse-path.js","../src/is-local-link.js","../src/prefix-helpers.js","../src/rewrite-link-path.js","../src/index.js"],"sourcesContent":["export function parsePath(path) {\n let pathname = path || `/`\n let search = ``\n let hash = ``\n\n const hashIndex = pathname.indexOf(`#`)\n if (hashIndex !== -1) {\n hash = pathname.slice(hashIndex)\n pathname = pathname.slice(0, hashIndex)\n }\n\n const searchIndex = pathname.indexOf(`?`)\n if (searchIndex !== -1) {\n search = pathname.slice(searchIndex)\n pathname = pathname.slice(0, searchIndex)\n }\n\n return {\n pathname: pathname,\n search: search === `?` ? `` : search,\n hash: hash === `#` ? `` : hash,\n }\n}\n","// Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js\nconst ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\\d+\\-.]*?:/\nconst isAbsolute = path => ABSOLUTE_URL_REGEX.test(path)\n\nexport const isLocalLink = path => {\n if (typeof path !== `string`) {\n return undefined\n // TODO(v5): Re-Add TypeError\n // throw new TypeError(`Expected a \\`string\\`, got \\`${typeof path}\\``)\n }\n\n return !isAbsolute(path)\n}\n","import { isLocalLink } from \"./is-local-link\"\n\nexport const getGlobalBasePrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __BASE_PATH__ !== `undefined`\n ? __BASE_PATH__\n : undefined\n : __BASE_PATH__\n\n// These global values are wrapped in typeof clauses to ensure the values exist.\n// This is especially problematic in unit testing of this component.\nexport const getGlobalPathPrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __PATH_PREFIX__ !== `undefined`\n ? __PATH_PREFIX__\n : undefined\n : __PATH_PREFIX__\n\nexport function withPrefix(path, prefix = getGlobalBasePrefix()) {\n if (!isLocalLink(path)) {\n return path\n }\n\n if (path.startsWith(`./`) || path.startsWith(`../`)) {\n return path\n }\n const base = prefix ?? getGlobalPathPrefix() ?? `/`\n\n return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${\n path.startsWith(`/`) ? path : `/${path}`\n }`\n}\n","import { resolve } from \"@gatsbyjs/reach-router\"\n// Specific import to treeshake Node.js stuff\nimport { applyTrailingSlashOption } from \"gatsby-page-utils/apply-trailing-slash-option\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { withPrefix } from \"./prefix-helpers\"\n\nconst isAbsolutePath = path => path?.startsWith(`/`)\n\nconst getGlobalTrailingSlash = () =>\n typeof __TRAILING_SLASH__ !== `undefined` ? __TRAILING_SLASH__ : undefined\n\nfunction applyTrailingSlashOptionOnPathnameOnly(path, option) {\n const { pathname, search, hash } = parsePath(path)\n const output = applyTrailingSlashOption(pathname, option)\n\n return `${output}${search}${hash}`\n}\n\nfunction absolutify(path, current) {\n // If it's already absolute, return as-is\n if (isAbsolutePath(path)) {\n return path\n }\n\n const option = getGlobalTrailingSlash()\n const absolutePath = resolve(path, current)\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(absolutePath, option)\n }\n\n return absolutePath\n}\n\nfunction applyPrefix(path) {\n const prefixed = withPrefix(path)\n const option = getGlobalTrailingSlash()\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(prefixed, option)\n }\n\n return prefixed\n}\n\nexport const rewriteLinkPath = (path, relativeTo) => {\n if (typeof path === `number`) {\n return path\n }\n if (!isLocalLink(path)) {\n return path\n }\n\n return isAbsolutePath(path) ? applyPrefix(path) : absolutify(path, relativeTo)\n}\n","import PropTypes from \"prop-types\"\nimport React from \"react\"\nimport { Link as ReachRouterLink, Location } from \"@gatsbyjs/reach-router\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { rewriteLinkPath } from \"./rewrite-link-path\"\nimport { withPrefix, getGlobalPathPrefix } from \"./prefix-helpers\"\n\nexport { parsePath, withPrefix }\n\nexport function withAssetPrefix(path) {\n return withPrefix(path, getGlobalPathPrefix())\n}\n\nconst NavLinkPropTypes = {\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n partiallyActive: PropTypes.bool,\n}\n\n// Set up IntersectionObserver\nconst createIntersectionObserver = (el, cb) => {\n const io = new window.IntersectionObserver(entries => {\n entries.forEach(entry => {\n if (el === entry.target) {\n // Check if element is within viewport, remove listener, destroy observer, and run link callback.\n // MSEdge doesn't currently support isIntersecting, so also test for an intersectionRatio > 0\n cb(entry.isIntersecting || entry.intersectionRatio > 0)\n }\n })\n })\n\n // Add element to the observer\n io.observe(el)\n\n return { instance: io, el }\n}\n\nfunction GatsbyLinkLocationWrapper(props) {\n return (\n <Location>\n {({ location }) => <GatsbyLink {...props} _location={location} />}\n </Location>\n )\n}\n\nclass GatsbyLink extends React.Component {\n constructor(props) {\n super(props)\n // Default to no support for IntersectionObserver\n let IOSupported = false\n if (typeof window !== `undefined` && window.IntersectionObserver) {\n IOSupported = true\n }\n\n this.state = {\n IOSupported,\n }\n this.abortPrefetch = null\n this.handleRef = this.handleRef.bind(this)\n }\n\n _prefetch() {\n let currentPath = window.location.pathname + window.location.search\n\n // reach router should have the correct state\n if (this.props._location && this.props._location.pathname) {\n currentPath = this.props._location.pathname + this.props._location.search\n }\n\n const rewrittenPath = rewriteLinkPath(this.props.to, currentPath)\n const parsed = parsePath(rewrittenPath)\n\n const newPathName = parsed.pathname + parsed.search\n\n // Prefetch is used to speed up next navigations. When you use it on the current navigation,\n // there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete\n if (currentPath !== newPathName) {\n return ___loader.enqueue(newPathName)\n }\n\n return undefined\n }\n\n componentWillUnmount() {\n if (!this.io) {\n return\n }\n const { instance, el } = this.io\n\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n\n instance.unobserve(el)\n instance.disconnect()\n }\n\n handleRef(ref) {\n if (\n this.props.innerRef &&\n Object.prototype.hasOwnProperty.call(this.props.innerRef, `current`)\n ) {\n this.props.innerRef.current = ref\n } else if (this.props.innerRef) {\n this.props.innerRef(ref)\n }\n\n if (this.state.IOSupported && ref) {\n // If IO supported and element reference found, setup Observer functionality\n this.io = createIntersectionObserver(ref, inViewPort => {\n if (inViewPort) {\n this.abortPrefetch = this._prefetch()\n } else {\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n }\n })\n }\n }\n\n defaultGetProps = ({ isPartiallyCurrent, isCurrent }) => {\n if (this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {\n return {\n className: [this.props.className, this.props.activeClassName]\n .filter(Boolean)\n .join(` `),\n style: { ...this.props.style, ...this.props.activeStyle },\n }\n }\n return null\n }\n\n render() {\n const {\n to,\n getProps = this.defaultGetProps,\n onClick,\n onMouseEnter,\n /* eslint-disable no-unused-vars */\n activeClassName: $activeClassName,\n activeStyle: $activeStyle,\n innerRef: $innerRef,\n partiallyActive,\n state,\n replace,\n _location,\n /* eslint-enable no-unused-vars */\n ...rest\n } = this.props\n\n if (process.env.NODE_ENV !== `production` && !isLocalLink(to)) {\n console.warn(\n `External link ${to} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`\n )\n }\n\n const prefixedTo = rewriteLinkPath(to, _location.pathname)\n if (!isLocalLink(prefixedTo)) {\n return <a href={prefixedTo} {...rest} />\n }\n\n return (\n <ReachRouterLink\n to={prefixedTo}\n state={state}\n getProps={getProps}\n innerRef={this.handleRef}\n onMouseEnter={e => {\n if (onMouseEnter) {\n onMouseEnter(e)\n }\n const parsed = parsePath(prefixedTo)\n ___loader.hovering(parsed.pathname + parsed.search)\n }}\n onClick={e => {\n if (onClick) {\n onClick(e)\n }\n\n if (\n e.button === 0 && // ignore right clicks\n !this.props.target && // let browser handle \"target=_blank\"\n !e.defaultPrevented && // onClick prevented default\n !e.metaKey && // ignore clicks with modifier keys...\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey\n ) {\n e.preventDefault()\n\n let shouldReplace = replace\n const isCurrent = encodeURI(prefixedTo) === _location.pathname\n\n if (typeof replace !== `boolean` && isCurrent) {\n shouldReplace = true\n }\n // Make sure the necessary scripts and data are\n // loaded before continuing.\n window.___navigate(prefixedTo, {\n state,\n replace: shouldReplace,\n })\n }\n\n return true\n }}\n {...rest}\n />\n )\n }\n}\n\nGatsbyLink.propTypes = {\n ...NavLinkPropTypes,\n onClick: PropTypes.func,\n to: PropTypes.string.isRequired,\n replace: PropTypes.bool,\n state: PropTypes.object,\n}\n\nexport const Link = React.forwardRef((props, ref) => (\n <GatsbyLinkLocationWrapper innerRef={ref} {...props} />\n))\n\nexport const navigate = (to, options) => {\n window.___navigate(rewriteLinkPath(to, window.location.pathname), options)\n}\n"],"names":["path","pathname","indexOf","hashIndex","hash","slice","searchIndex","search","ABSOLUTE_URL_REGEX","test","isAbsolute","process","env","NODE_ENV","__PATH_PREFIX__","undefined","prefix","__BASE_PATH__","getGlobalBasePrefix","isLocalLink","startsWith","getGlobalPathPrefix","base","endsWith","__TRAILING_SLASH__","option","parsePath","applyTrailingSlashOption","relativeTo","withPrefix","getGlobalTrailingSlash","prefixed","applyPrefix","current","isAbsolutePath","resolve","absolutePath","absolutify","activeClassName","PropTypes","string","activeStyle","object","partiallyActive","bool","props","React","Location","location","GatsbyLink","_location","Component","constructor","super","this","defaultGetProps","isPartiallyCurrent","isCurrent","className","filter","Boolean","join","style","window","IntersectionObserver","IOSupported","state","abortPrefetch","handleRef","bind","_prefetch","currentPath","rewriteLinkPath","to","parsed","newPathName","enqueue","componentWillUnmount","io","instance","el","abort","unobserve","disconnect","ref","innerRef","Object","prototype","hasOwnProperty","call","cb","entries","forEach","entry","target","isIntersecting","intersectionRatio","observe","createIntersectionObserver","inViewPort","render","getProps","onClick","onMouseEnter","replace","rest","console","warn","prefixedTo","ReachRouterLink","e","___loader","hovering","button","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","preventDefault","encodeURI","shouldReplace","___navigate","href","propTypes","NavLinkPropTypes","func","isRequired","Link","forwardRef","GatsbyLinkLocationWrapper","options"],"mappings":"gcAA0BA,GACxB,MAAeA,GAAS,MACV,KACF,GAEZ,QAAkBC,EAASC,QAAS,MACjB,IAAfC,IACFC,EAAOH,EAASI,MAAMF,GACtBF,EAAWA,EAASI,MAAM,EAAGF,IAG/B,QAAoBF,EAASC,QAAS,KAMtC,OALqB,IAAjBI,IACFC,EAASN,EAASI,MAAMC,GACxBL,EAAWA,EAASI,MAAM,EAAGC,IAGxB,CACLL,SAAUA,EACVM,OAAoB,MAAZA,EAAkB,GAAIA,EAC9BH,KAAgB,MAAVA,EAAgB,GAAIA,GCnB9B,QAA2B,+BAGAJ,IACzB,GAAqB,mBAMrB,OATiBA,CAAAA,GAAQQ,EAAmBC,KAAKT,GASzCU,CAAWV,MCAc,IACP,eAA1BW,QAAQC,IAAIC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,SAAUD,GAASvC,OAGxB,CAAC4B,EAAI0D,KAC3BpE,OAAO2D,YAAYlD,EAAgBC,EAAIV,OAAOf,SAAS/C,UAAWkI"}
1
+ {"version":3,"file":"index.modern.mjs","sources":["../src/parse-path.js","../src/is-local-link.js","../src/prefix-helpers.js","../src/rewrite-link-path.js","../src/index.js"],"sourcesContent":["export function parsePath(path) {\n let pathname = path || `/`\n let search = ``\n let hash = ``\n\n const hashIndex = pathname.indexOf(`#`)\n if (hashIndex !== -1) {\n hash = pathname.slice(hashIndex)\n pathname = pathname.slice(0, hashIndex)\n }\n\n const searchIndex = pathname.indexOf(`?`)\n if (searchIndex !== -1) {\n search = pathname.slice(searchIndex)\n pathname = pathname.slice(0, searchIndex)\n }\n\n return {\n pathname: pathname,\n search: search === `?` ? `` : search,\n hash: hash === `#` ? `` : hash,\n }\n}\n","// Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js\nconst ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\\d+\\-.]*?:/\nconst isAbsolute = path => ABSOLUTE_URL_REGEX.test(path)\n\nexport const isLocalLink = path => {\n if (typeof path !== `string`) {\n return undefined\n // TODO(v5): Re-Add TypeError\n // throw new TypeError(`Expected a \\`string\\`, got \\`${typeof path}\\``)\n }\n\n return !isAbsolute(path)\n}\n","import { isLocalLink } from \"./is-local-link\"\n\nexport const getGlobalBasePrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __BASE_PATH__ !== `undefined`\n ? __BASE_PATH__\n : undefined\n : __BASE_PATH__\n\n// These global values are wrapped in typeof clauses to ensure the values exist.\n// This is especially problematic in unit testing of this component.\nexport const getGlobalPathPrefix = () =>\n process.env.NODE_ENV !== `production`\n ? typeof __PATH_PREFIX__ !== `undefined`\n ? __PATH_PREFIX__\n : undefined\n : __PATH_PREFIX__\n\nexport function withPrefix(path, prefix = getGlobalBasePrefix()) {\n if (!isLocalLink(path)) {\n return path\n }\n\n if (path.startsWith(`./`) || path.startsWith(`../`)) {\n return path\n }\n const base = prefix ?? getGlobalPathPrefix() ?? `/`\n\n return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${\n path.startsWith(`/`) ? path : `/${path}`\n }`\n}\n","import { resolve } from \"@gatsbyjs/reach-router\"\n// Specific import to treeshake Node.js stuff\nimport { applyTrailingSlashOption } from \"gatsby-page-utils/apply-trailing-slash-option\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { withPrefix } from \"./prefix-helpers\"\n\nconst isAbsolutePath = path => path?.startsWith(`/`)\n\nconst getGlobalTrailingSlash = () =>\n typeof __TRAILING_SLASH__ !== `undefined` ? __TRAILING_SLASH__ : undefined\n\nfunction applyTrailingSlashOptionOnPathnameOnly(path, option) {\n const { pathname, search, hash } = parsePath(path)\n const output = applyTrailingSlashOption(pathname, option)\n\n return `${output}${search}${hash}`\n}\n\nfunction absolutify(path, current) {\n // If it's already absolute, return as-is\n if (isAbsolutePath(path)) {\n return path\n }\n\n const option = getGlobalTrailingSlash()\n const absolutePath = resolve(path, current)\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(absolutePath, option)\n }\n\n return absolutePath\n}\n\nfunction applyPrefix(path) {\n const prefixed = withPrefix(path)\n const option = getGlobalTrailingSlash()\n\n if (option === `always` || option === `never`) {\n return applyTrailingSlashOptionOnPathnameOnly(prefixed, option)\n }\n\n return prefixed\n}\n\nexport const rewriteLinkPath = (path, relativeTo) => {\n if (typeof path === `number`) {\n return path\n }\n if (!isLocalLink(path)) {\n return path\n }\n\n return isAbsolutePath(path) ? applyPrefix(path) : absolutify(path, relativeTo)\n}\n","import PropTypes from \"prop-types\"\nimport React from \"react\"\nimport { Link as ReachRouterLink, Location } from \"@gatsbyjs/reach-router\"\nimport { parsePath } from \"./parse-path\"\nimport { isLocalLink } from \"./is-local-link\"\nimport { rewriteLinkPath } from \"./rewrite-link-path\"\nimport { withPrefix, getGlobalPathPrefix } from \"./prefix-helpers\"\n\nexport { parsePath, withPrefix }\n\nexport function withAssetPrefix(path) {\n return withPrefix(path, getGlobalPathPrefix())\n}\n\nconst NavLinkPropTypes = {\n activeClassName: PropTypes.string,\n activeStyle: PropTypes.object,\n partiallyActive: PropTypes.bool,\n}\n\n// Set up IntersectionObserver\nconst createIntersectionObserver = (el, cb) => {\n const io = new window.IntersectionObserver(entries => {\n entries.forEach(entry => {\n if (el === entry.target) {\n // Check if element is within viewport, remove listener, destroy observer, and run link callback.\n // MSEdge doesn't currently support isIntersecting, so also test for an intersectionRatio > 0\n cb(entry.isIntersecting || entry.intersectionRatio > 0)\n }\n })\n })\n\n // Add element to the observer\n io.observe(el)\n\n return { instance: io, el }\n}\n\nfunction GatsbyLinkLocationWrapper(props) {\n return (\n <Location>\n {({ location }) => <GatsbyLink {...props} _location={location} />}\n </Location>\n )\n}\n\nclass GatsbyLink extends React.Component {\n constructor(props) {\n super(props)\n // Default to no support for IntersectionObserver\n let IOSupported = false\n if (typeof window !== `undefined` && window.IntersectionObserver) {\n IOSupported = true\n }\n\n this.state = {\n IOSupported,\n }\n this.abortPrefetch = null\n this.handleRef = this.handleRef.bind(this)\n }\n\n _prefetch() {\n let currentPath = window.location.pathname + window.location.search\n\n // reach router should have the correct state\n if (this.props._location && this.props._location.pathname) {\n currentPath = this.props._location.pathname + this.props._location.search\n }\n\n const rewrittenPath = rewriteLinkPath(this.props.to, currentPath)\n const parsed = parsePath(rewrittenPath)\n\n const newPathName = parsed.pathname + parsed.search\n\n // Prefetch is used to speed up next navigations. When you use it on the current navigation,\n // there could be a race-condition where Chrome uses the stale data instead of waiting for the network to complete\n if (currentPath !== newPathName) {\n return ___loader.enqueue(newPathName)\n }\n\n return undefined\n }\n\n componentWillUnmount() {\n if (!this.io) {\n return\n }\n const { instance, el } = this.io\n\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n\n instance.unobserve(el)\n instance.disconnect()\n }\n\n handleRef(ref) {\n if (\n this.props.innerRef &&\n Object.prototype.hasOwnProperty.call(this.props.innerRef, `current`)\n ) {\n this.props.innerRef.current = ref\n } else if (this.props.innerRef) {\n this.props.innerRef(ref)\n }\n\n if (this.state.IOSupported && ref) {\n // If IO supported and element reference found, setup Observer functionality\n this.io = createIntersectionObserver(ref, inViewPort => {\n if (inViewPort) {\n this.abortPrefetch = this._prefetch()\n } else {\n if (this.abortPrefetch) {\n this.abortPrefetch.abort()\n }\n }\n })\n }\n }\n\n defaultGetProps = ({ isPartiallyCurrent, isCurrent }) => {\n if (this.props.partiallyActive ? isPartiallyCurrent : isCurrent) {\n return {\n className: [this.props.className, this.props.activeClassName]\n .filter(Boolean)\n .join(` `),\n style: { ...this.props.style, ...this.props.activeStyle },\n }\n }\n return null\n }\n\n render() {\n const {\n to,\n getProps = this.defaultGetProps,\n onClick,\n onMouseEnter,\n /* eslint-disable no-unused-vars */\n activeClassName: $activeClassName,\n activeStyle: $activeStyle,\n innerRef: $innerRef,\n partiallyActive,\n state,\n replace,\n _location,\n /* eslint-enable no-unused-vars */\n ...rest\n } = this.props\n\n if (process.env.NODE_ENV !== `production` && !isLocalLink(to)) {\n console.warn(\n `External link ${to} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`\n )\n }\n\n const prefixedTo = rewriteLinkPath(to, _location.pathname)\n if (!isLocalLink(prefixedTo)) {\n return <a href={prefixedTo} {...rest} />\n }\n\n return (\n <ReachRouterLink\n to={prefixedTo}\n state={state}\n getProps={getProps}\n innerRef={this.handleRef}\n onMouseEnter={e => {\n if (onMouseEnter) {\n onMouseEnter(e)\n }\n const parsed = parsePath(prefixedTo)\n ___loader.hovering(parsed.pathname + parsed.search)\n }}\n onClick={e => {\n if (onClick) {\n onClick(e)\n }\n\n if (\n e.button === 0 && // ignore right clicks\n !this.props.target && // let browser handle \"target=_blank\"\n !e.defaultPrevented && // onClick prevented default\n !e.metaKey && // ignore clicks with modifier keys...\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey\n ) {\n e.preventDefault()\n\n let shouldReplace = replace\n const isCurrent = encodeURI(prefixedTo) === _location.pathname\n\n if (typeof replace !== `boolean` && isCurrent) {\n shouldReplace = true\n }\n // Make sure the necessary scripts and data are\n // loaded before continuing.\n window.___navigate(prefixedTo, {\n state,\n replace: shouldReplace,\n })\n }\n\n return true\n }}\n {...rest}\n />\n )\n }\n}\n\nGatsbyLink.propTypes = {\n ...NavLinkPropTypes,\n onClick: PropTypes.func,\n to: PropTypes.string.isRequired,\n replace: PropTypes.bool,\n state: PropTypes.object,\n}\n\nexport const Link = React.forwardRef((props, ref) => (\n <GatsbyLinkLocationWrapper innerRef={ref} {...props} />\n))\n\nexport const navigate = (to, options) => {\n window.___navigate(rewriteLinkPath(to, window.location.pathname), options)\n}\n"],"names":["parsePath","path","pathname","search","hash","hashIndex","indexOf","slice","searchIndex","isLocalLink","ABSOLUTE_URL_REGEX","test","isAbsolute","getGlobalPathPrefix","process","env","NODE_ENV","__PATH_PREFIX__","undefined","withPrefix","prefix","__BASE_PATH__","getGlobalBasePrefix","_ref","startsWith","base","endsWith","isAbsolutePath","getGlobalTrailingSlash","__TRAILING_SLASH__","applyTrailingSlashOptionOnPathnameOnly","option","applyTrailingSlashOption","rewriteLinkPath","relativeTo","prefixed","applyPrefix","current","absolutePath","resolve","absolutify","withAssetPrefix","activeClassName","PropTypes","string","activeStyle","object","partiallyActive","bool","GatsbyLinkLocationWrapper","props","React","createElement","Location","location","GatsbyLink","_extends","_location","Component","constructor","super","defaultGetProps","isPartiallyCurrent","isCurrent","this","className","filter","Boolean","join","style","IOSupported","window","IntersectionObserver","state","abortPrefetch","handleRef","bind","_prefetch","currentPath","parsed","to","newPathName","enqueue","componentWillUnmount","io","instance","el","abort","unobserve","disconnect","ref","innerRef","Object","prototype","hasOwnProperty","call","cb","entries","forEach","entry","target","isIntersecting","intersectionRatio","observe","createIntersectionObserver","inViewPort","render","_this$props","getProps","onClick","onMouseEnter","replace","rest","_objectWithoutPropertiesLoose","_excluded","console","warn","prefixedTo","ReachRouterLink","e","___loader","hovering","button","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","preventDefault","shouldReplace","encodeURI","___navigate","href","propTypes","NavLinkPropTypes","func","isRequired","Link","forwardRef","navigate","options"],"mappings":"qbAAO,SAAkBA,EAACC,GACxB,IAAYC,EAAGD,GAAS,IACpBE,EAAU,GACNC,EAAI,GAEZ,MAAMC,EAAYH,EAASI,QAAS,MACjB,IAAfD,IACFD,EAAOF,EAASK,MAAMF,GACtBH,EAAWA,EAASK,MAAM,EAAGF,IAG/B,QAAoBH,EAASI,QAAS,KAMtC,OALqB,IAAjBE,IACFL,EAASD,EAASK,MAAMC,GACxBN,EAAWA,EAASK,MAAM,EAAGC,IAGxB,CACLN,SAAUA,EACVC,OAAoB,MAAZA,EAAkB,GAAIA,EAC9BC,KAAgB,MAAVA,EAAgB,GAAIA,EAE9B,CCrBA,QAA2B,6BAGdK,EAAcR,IACzB,GAAqB,iBAANA,EAMf,OATiBA,IAAQS,EAAmBC,KAAKV,GASzCW,CAAWX,EAAI,ECAZY,EAAsB,IACP,eAA1BC,QAAQC,IAAIC,SACoB,oBAArBC,gBACLA,qBACAC,EACFD,gBAEC,SAAmBE,EAAClB,EAAMmB,EAhBE,KACP,eAA1BN,QAAQC,IAAIC,SACkB,oBAANK,cAClBA,mBACAH,EACFG,cAWoCC,IACxC,IAAAC,EAAA,IAAKd,EAAYR,GACf,OAAOA,EAGT,GAAIA,EAAKuB,WAAY,OAAQvB,EAAKuB,WAAY,OAC5C,OACFvB,EACA,MAAUwB,SAAAF,EAAS,MAANH,EAAAA,EAAUP,OAA0B,IAEjD,MAAQ,GAAM,MAAJY,GAAAA,EAAMC,SAAU,KAAMD,EAAKlB,MAAM,GAAI,GAAKkB,IAClDxB,EAAKuB,WAAY,KAAMvB,EAAQ,IAAGA,KAEtC,CCxBA,MAAM0B,EAAiB1B,GAAY,MAAJA,OAAI,EAAJA,EAAMuB,WAA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,EAAAC,cAACH,EAAyBO,EAAA,CAACmC,SAAUD,GAASxC,KAGnCyF,EAAW,CAAC3D,EAAI4D,KAC3BrE,OAAO4D,YAAYlG,EAAgB+C,EAAIT,OAAOjB,SAASpD,UAAW0I,EACpE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-link",
3
3
  "description": "An enhanced Link component for Gatsby sites with support for resource prefetching",
4
- "version": "5.4.0-next.1",
4
+ "version": "5.4.0",
5
5
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@types/reach__router": "^1.3.10",
26
- "gatsby-page-utils": "^3.4.0-next.1",
26
+ "gatsby-page-utils": "^3.4.0",
27
27
  "prop-types": "^15.8.1"
28
28
  },
29
29
  "devDependencies": {
@@ -51,5 +51,5 @@
51
51
  "engines": {
52
52
  "node": ">=18.0.0"
53
53
  },
54
- "gitHead": "7103697710ba19ac41ef3b384c1af5143f71c176"
54
+ "gitHead": "12252dd997c7dd8cb21cd0b512830295c2f52fdb"
55
55
  }