@vuepress/plugin-redirect 2.0.0-rc.124 → 2.0.0-rc.125

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.
Files changed (35) hide show
  1. package/{lib/RedirectModal-DopLrY65.d.ts → dist/RedirectModal-BYwO_dsb.d.ts} +3 -6
  2. package/dist/RedirectModal-BrOzOt-4.js +2 -0
  3. package/dist/RedirectModal-BrOzOt-4.js.map +1 -0
  4. package/{lib/behavior-D5-7wmJ-.d.ts → dist/behavior-CskAbQua.d.ts} +1 -1
  5. package/{lib → dist}/cli/index.js +1 -1
  6. package/dist/client/components/RedirectModal.d.ts +2 -0
  7. package/dist/client/components/RedirectModal.js +1 -0
  8. package/{lib → dist}/client/config.d.ts +1 -3
  9. package/{lib → dist}/client/config.js +1 -1
  10. package/{lib → dist}/client/index.d.ts +2 -2
  11. package/dist/client/index.js +1 -0
  12. package/{lib/locales-CrXL-ZZP.d.ts → dist/locales-Z6zBEIHt.d.ts} +1 -1
  13. package/{lib → dist}/node/index.d.ts +2 -2
  14. package/{lib → dist}/node/index.js +1 -1
  15. package/{lib/normalizePath-DCapcto5.js → dist/normalizePath-NaIHZnk8.js} +1 -1
  16. package/{lib/normalizePath-DCapcto5.js.map → dist/normalizePath-NaIHZnk8.js.map} +1 -1
  17. package/{lib/setupRedirect-DB0Ip2i-.js → dist/setupRedirect-BTZPAp92.js} +2 -2
  18. package/{lib/setupRedirect-DB0Ip2i-.js.map → dist/setupRedirect-BTZPAp92.js.map} +1 -1
  19. package/{lib/useRedirectInfo-BhfN7KrZ.js → dist/useRedirectInfo-CSkKkjhg.js} +1 -1
  20. package/{lib/useRedirectInfo-BhfN7KrZ.js.map → dist/useRedirectInfo-CSkKkjhg.js.map} +1 -1
  21. package/package.json +10 -10
  22. package/lib/client/components/RedirectModal.d.ts +0 -2
  23. package/lib/client/components/RedirectModal.js +0 -2
  24. package/lib/client/components/RedirectModal.js.map +0 -1
  25. package/lib/client/index.js +0 -1
  26. /package/{lib → dist}/cli/index.d.ts +0 -0
  27. /package/{lib → dist}/cli/index.js.map +0 -0
  28. /package/{lib → dist}/client/config.js.map +0 -0
  29. /package/{lib → dist}/client/styles/redirect-modal.css +0 -0
  30. /package/{lib → dist}/client/styles/redirect-modal.css.map +0 -0
  31. /package/{lib → dist}/client/styles/vars.css +0 -0
  32. /package/{lib → dist}/client/styles/vars.css.map +0 -0
  33. /package/{lib → dist}/getRedirectHTML-C9SBJAfB.js +0 -0
  34. /package/{lib → dist}/getRedirectHTML-C9SBJAfB.js.map +0 -0
  35. /package/{lib → dist}/node/index.js.map +0 -0
@@ -1,11 +1,8 @@
1
- import { t as RedirectBehaviorConfig } from "./behavior-D5-7wmJ-.js";
2
- import { t as RedirectPluginLocaleData } from "./locales-CrXL-ZZP.js";
1
+ import { t as RedirectBehaviorConfig } from "./behavior-CskAbQua.js";
2
+ import { t as RedirectPluginLocaleData } from "./locales-Z6zBEIHt.js";
3
3
  import * as vue from "vue";
4
4
  import { PropType, VNode } from "vue";
5
5
  import { ExactLocaleConfig } from "@vuepress/helper/client";
6
- import "@vuepress/helper/transition/fade-in-scale-up.css";
7
- import "./client/styles/redirect-modal.css";
8
-
9
6
  //#region src/client/types.d.ts
10
7
  type RedirectPluginLocaleConfig = ExactLocaleConfig<RedirectPluginLocaleData>;
11
8
  //#endregion
@@ -31,4 +28,4 @@ declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
31
28
  }>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
32
29
  //#endregion
33
30
  export { _default as t };
34
- //# sourceMappingURL=RedirectModal-DopLrY65.d.ts.map
31
+ //# sourceMappingURL=RedirectModal-BYwO_dsb.d.ts.map
@@ -0,0 +1,2 @@
1
+ import{n as e,r as t,t as n}from"./useRedirectInfo-CSkKkjhg.js";import{useScrollLock as r}from"@vueuse/core";import{TransitionGroup as i,computed as a,defineComponent as o,h as s,nextTick as c,onBeforeUnmount as l,onMounted as u,ref as d,watch as f}from"vue";import{useData as p,useRouter as m}from"vuepress/client";import"@vuepress/helper/transition/fade-in-scale-up.css";import"./client/styles/redirect-modal.css";var h=o({name:`RedirectModal`,props:{config:{type:Object,required:!0},locales:{type:Object,required:!0}},setup(o){let h=m(),{routeLocale:g,routePath:_}=p(),v=n(o.config),y=d(),b=r(y),x=d(!1),S=a(()=>{if(!v.value)return null;let{lang:e,localePath:t}=v.value,n=[o.locales[t],o.locales[g.value]];return{hint:n.map(({hint:t})=>t.replace(`$1`,e)),switch:n.map(({switch:t})=>t.replace(`$1`,e)).join(` / `),cancel:n.map(({cancel:e})=>e).join(` / `),remember:n.map(({remember:e})=>e).join(` / `)}}),C=()=>{t.value[g.value]=!0,x.value&&(e.value[g.value]=!0),b.value=!1};return f(_,()=>{b.value=!1}),u(async()=>{y.value=document.body,await c(),v.value&&!t.value[g.value]&&!e.value[g.value]&&(b.value=!0)}),l(()=>{b.value=!1}),()=>s(i,{name:`fade-in-scale-up`},()=>b.value?s(`div`,{key:`mask`,class:`redirect-modal-mask`},s(`div`,{key:`popup`,class:`redirect-modal-wrapper`},[s(`div`,{class:`redirect-modal-content`},S.value?.hint.map(e=>s(`p`,e))),s(`div`,{class:`redirect-modal-hint`},[s(`input`,{id:`remember-redirect`,type:`checkbox`,value:x.value,onChange:()=>{x.value=!x.value}}),s(`label`,{for:`remember-redirect`},S.value?.remember)]),s(`button`,{type:`button`,class:`redirect-modal-action primary`,onClick:()=>{C(),h.replace(_.value.replace(g.value,v.value.localePath))}},S.value?.switch),s(`button`,{type:`button`,class:`redirect-modal-action`,onClick:()=>{C()}},S.value?.cancel)])):null)}});export{h as t};
2
+ //# sourceMappingURL=RedirectModal-BrOzOt-4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedirectModal-BrOzOt-4.js","names":[],"sources":["../src/client/components/RedirectModal.ts"],"sourcesContent":["import { useScrollLock } from '@vueuse/core'\nimport type { PropType, VNode } from 'vue'\nimport {\n TransitionGroup,\n computed,\n defineComponent,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n} from 'vue'\nimport { useData, useRouter } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { useRedirectInfo } from '../composables/index.js'\nimport type { RedirectPluginLocaleConfig } from '../types.js'\nimport { statusLocalStorage, statusSessionStorage } from '../utils/index.js'\n\nimport '@vuepress/helper/transition/fade-in-scale-up.css'\nimport '../styles/redirect-modal.css'\n\nexport default defineComponent({\n name: 'RedirectModal',\n\n props: {\n config: {\n type: Object as PropType<RedirectBehaviorConfig>,\n required: true,\n },\n\n locales: {\n type: Object as PropType<RedirectPluginLocaleConfig>,\n required: true,\n },\n },\n\n setup(props) {\n const router = useRouter()\n const { routeLocale, routePath } = useData()\n const redirectInfo = useRedirectInfo(props.config)\n\n const body = ref<HTMLElement>()\n // lock body scroll when modal is displayed\n const showModal = useScrollLock(body)\n const shouldRemember = ref(false)\n\n const locale = computed(() => {\n if (!redirectInfo.value) return null\n\n const { lang, localePath } = redirectInfo.value\n const locales = [\n props.locales[localePath],\n props.locales[routeLocale.value],\n ]\n\n return {\n hint: locales.map(({ hint }) => hint.replace('$1', lang)),\n switch: locales\n .map(({ switch: switchText }) => switchText.replace('$1', lang))\n .join(' / '),\n cancel: locales.map(({ cancel }) => cancel).join(' / '),\n remember: locales.map(({ remember }) => remember).join(' / '),\n }\n })\n\n const updateState = (): void => {\n statusSessionStorage.value[routeLocale.value] = true\n if (shouldRemember.value)\n statusLocalStorage.value[routeLocale.value] = true\n\n showModal.value = false\n }\n\n watch(routePath, () => {\n showModal.value = false\n })\n\n onMounted(async () => {\n body.value = document.body\n\n await nextTick()\n\n if (\n redirectInfo.value &&\n !statusSessionStorage.value[routeLocale.value] &&\n !statusLocalStorage.value[routeLocale.value]\n )\n showModal.value = true\n })\n\n onBeforeUnmount(() => {\n showModal.value = false\n })\n\n return (): VNode | null =>\n h(TransitionGroup, { name: 'fade-in-scale-up' }, () =>\n showModal.value\n ? h(\n 'div',\n { key: 'mask', class: 'redirect-modal-mask' },\n h(\n 'div',\n {\n key: 'popup',\n class: 'redirect-modal-wrapper',\n },\n [\n h(\n 'div',\n { class: 'redirect-modal-content' },\n locale.value?.hint.map((text) => h('p', text)),\n ),\n h('div', { class: 'redirect-modal-hint' }, [\n h('input', {\n id: 'remember-redirect',\n type: 'checkbox',\n value: shouldRemember.value,\n onChange: () => {\n shouldRemember.value = !shouldRemember.value\n },\n }),\n h(\n 'label',\n { for: 'remember-redirect' },\n locale.value?.remember,\n ),\n ]),\n h(\n 'button',\n {\n type: 'button',\n class: 'redirect-modal-action primary',\n onClick: () => {\n updateState()\n void router.replace(\n routePath.value.replace(\n routeLocale.value,\n redirectInfo.value!.localePath,\n ),\n )\n },\n },\n locale.value?.switch,\n ),\n h(\n 'button',\n {\n type: 'button',\n class: 'redirect-modal-action',\n onClick: () => {\n updateState()\n },\n },\n locale.value?.cancel,\n ),\n ],\n ),\n )\n : null,\n )\n },\n})\n"],"mappings":"gaAsBA,IAAA,EAAe,EAAgB,CAC7B,KAAM,gBAEN,MAAO,CACL,OAAQ,CACN,KAAM,OACN,SAAU,GACX,CAED,QAAS,CACP,KAAM,OACN,SAAU,GACX,CACF,CAED,MAAM,EAAO,CACX,IAAM,EAAS,GAAW,CACpB,CAAE,cAAa,aAAc,GAAS,CACtC,EAAe,EAAgB,EAAM,OAAO,CAE5C,EAAO,GAAkB,CAEzB,EAAY,EAAc,EAAK,CAC/B,EAAiB,EAAI,GAAM,CAE3B,EAAS,MAAe,CAC5B,GAAI,CAAC,EAAa,MAAO,OAAO,KAEhC,GAAM,CAAE,OAAM,cAAe,EAAa,MACpC,EAAU,CACd,EAAM,QAAQ,GACd,EAAM,QAAQ,EAAY,OAC3B,CAED,MAAO,CACL,KAAM,EAAQ,KAAK,CAAE,UAAW,EAAK,QAAQ,KAAM,EAAK,CAAC,CACzD,OAAQ,EACL,KAAK,CAAE,OAAQ,KAAiB,EAAW,QA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AAa,EAEhB,CACD,EAAO,OAAO,OACf,CACF,CACF,CACF,CACD,KACL,EAEN,CAAC"}
@@ -49,4 +49,4 @@ interface RedirectBehaviorConfig extends Required<RedirectBehaviorOptions> {
49
49
  }
50
50
  //#endregion
51
51
  export { RedirectBehaviorOptions as n, RedirectBehaviorConfig as t };
52
- //# sourceMappingURL=behavior-D5-7wmJ-.d.ts.map
52
+ //# sourceMappingURL=behavior-CskAbQua.d.ts.map
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"../getRedirectHTML-C9SBJAfB.js";import{removeEndingSlash as t,removeLeadingSlash as n}from"@vuepress/helper";import{createCommand as r}from"commander";import{loadUserConfig as i,resolveAppConfig as a,resolveCliAppConfig as o,resolveUserConfigConventionalPath as s,resolveUserConfigPath as c,transformUserConfigToPlugin as l}from"vuepress/cli";import{createBuildApp as u}from"vuepress/core";import{fs as d,logger as f,path as p}from"vuepress/utils";var m=`2.0.0-rc.124`;const h=r(`vp-redirect`);h.summary(`Generate redirect site`).description(`Generate redirect site for current VuePress project`).option(`--hostname <hostname>`,`Hostname to redirect to (E.g.: https://new.example.com/)`,`/`).option(`-c, --config [config]`,`Set path to config file`).option(`--cache [cache]`,`Set the directory of the cache files`).option(`--temp [temp]`,`Set the directory of the temporary files`).option(`--clean-cache`,`Clean the cache files before generation`).option(`--clean-temp`,`Clean the temporary files before generation`).argument(`<source>`,`Source directory of VuePress project`).argument(`[output]`,`Output folder (default: .vuepress/redirect relative to source folder)`).action(async(r,m,g)=>{process.env.NODE_ENV??=`production`,d.existsSync(r)||h.error(`Source directory ${r} does not exist!`);let _=o(r,{}),{userConfig:v}=await i(g.config?c(g.config):s(_.source)),y=a({defaultAppConfig:{cache:g.cache,temp:g.temp},cliAppConfig:_,userConfig:v});if(y==null)return;let b=u(y);b.use(l(v,_.source)),g.cleanTemp===!0&&(f.info(`Cleaning temp...`),await d.remove(b.dir.temp())),g.cleanCache===!0&&(f.info(`Cleaning cache...`),await d.remove(b.dir.cache()));let x=m?p.join(process.cwd(),m):p.join(b.dir.source(),`.vuepress`,`redirect`);await d.emptyDir(x),f.info(`Initializing VuePress and preparing data...`),await b.init(),f.info(`Generating redirect pages...`),await Promise.all(b.pages.map(r=>{let i=`${t(g.hostname)}${b.siteData.base}${n(r.path)}`,a=p.join(x,n(r.path.replace(/\/$/,`/index.html`)));return d.ensureDir(p.dirname(a)).then(()=>d.writeFile(a,e(i)))}))}),h.version(m),h.showHelpAfterError(`add --help for additional information`),await h.parseAsync();export{};
2
+ import{t as e}from"../getRedirectHTML-C9SBJAfB.js";import{removeEndingSlash as t,removeLeadingSlash as n}from"@vuepress/helper";import{createCommand as r}from"commander";import{loadUserConfig as i,resolveAppConfig as a,resolveCliAppConfig as o,resolveUserConfigConventionalPath as s,resolveUserConfigPath as c,transformUserConfigToPlugin as l}from"vuepress/cli";import{createBuildApp as u}from"vuepress/core";import{fs as d,logger as f,path as p}from"vuepress/utils";var m=`2.0.0-rc.125`;const h=r(`vp-redirect`);h.summary(`Generate redirect site`).description(`Generate redirect site for current VuePress project`).option(`--hostname <hostname>`,`Hostname to redirect to (E.g.: https://new.example.com/)`,`/`).option(`-c, --config [config]`,`Set path to config file`).option(`--cache [cache]`,`Set the directory of the cache files`).option(`--temp [temp]`,`Set the directory of the temporary files`).option(`--clean-cache`,`Clean the cache files before generation`).option(`--clean-temp`,`Clean the temporary files before generation`).argument(`<source>`,`Source directory of VuePress project`).argument(`[output]`,`Output folder (default: .vuepress/redirect relative to source folder)`).action(async(r,m,g)=>{process.env.NODE_ENV??=`production`,d.existsSync(r)||h.error(`Source directory ${r} does not exist!`);let _=o(r,{}),{userConfig:v}=await i(g.config?c(g.config):s(_.source)),y=a({defaultAppConfig:{cache:g.cache,temp:g.temp},cliAppConfig:_,userConfig:v});if(y==null)return;let b=u(y);b.use(l(v,_.source)),g.cleanTemp===!0&&(f.info(`Cleaning temp...`),await d.remove(b.dir.temp())),g.cleanCache===!0&&(f.info(`Cleaning cache...`),await d.remove(b.dir.cache()));let x=m?p.join(process.cwd(),m):p.join(b.dir.source(),`.vuepress`,`redirect`);await d.emptyDir(x),f.info(`Initializing VuePress and preparing data...`),await b.init(),f.info(`Generating redirect pages...`),await Promise.all(b.pages.map(r=>{let i=`${t(g.hostname)}${b.siteData.base}${n(r.path)}`,a=p.join(x,n(r.path.replace(/\/$/,`/index.html`)));return d.ensureDir(p.dirname(a)).then(()=>d.writeFile(a,e(i)))}))}),h.version(m),h.showHelpAfterError(`add --help for additional information`),await h.parseAsync();export{};
3
3
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { t as _default } from "../../RedirectModal-BYwO_dsb.js";
2
+ export { _default as default };
@@ -0,0 +1 @@
1
+ import{t as e}from"../../RedirectModal-BrOzOt-4.js";export{e as default};
@@ -1,7 +1,5 @@
1
- import { t as RedirectBehaviorConfig } from "../behavior-D5-7wmJ-.js";
1
+ import { t as RedirectBehaviorConfig } from "../behavior-CskAbQua.js";
2
2
  import * as vuepress_client0 from "vuepress/client";
3
- import "./styles/vars.css";
4
-
5
3
  //#region src/client/config.d.ts
6
4
  declare const config: RedirectBehaviorConfig;
7
5
  declare const _default: vuepress_client0.ClientConfig;
@@ -1,2 +1,2 @@
1
- import{n as e,t}from"../setupRedirect-DB0Ip2i-.js";import{h as n}from"vue";import{defineClientConfig as r}from"vuepress/client";import i from"@vuepress/plugin-redirect/modal";import"./styles/vars.css";const a=__REDIRECT_CONFIG__;var o=r({setup(){__REDIRECT_DIRECT__&&t(a),__VUEPRESS_DEV__&&e(a)},...__REDIRECT_MODAL__?{rootComponents:[()=>n(i,{config:a,locales:__REDIRECT_LOCALES__})]}:{}});export{a as config,o as default};
1
+ import{n as e,t}from"../setupRedirect-BTZPAp92.js";import{h as n}from"vue";import{defineClientConfig as r}from"vuepress/client";import i from"@vuepress/plugin-redirect/modal";import"./styles/vars.css";const a=__REDIRECT_CONFIG__;var o=r({setup(){__REDIRECT_DIRECT__&&t(a),__VUEPRESS_DEV__&&e(a)},...__REDIRECT_MODAL__?{rootComponents:[()=>n(i,{config:a,locales:__REDIRECT_LOCALES__})]}:{}});export{a as config,o as default};
2
2
  //# sourceMappingURL=config.js.map
@@ -1,5 +1,5 @@
1
- import { t as RedirectBehaviorConfig } from "../behavior-D5-7wmJ-.js";
2
- import { t as _default } from "../RedirectModal-DopLrY65.js";
1
+ import { t as RedirectBehaviorConfig } from "../behavior-CskAbQua.js";
2
+ import { t as _default } from "../RedirectModal-BYwO_dsb.js";
3
3
  import { ComputedRef } from "vue";
4
4
 
5
5
  //#region src/client/composables/setupDevServerRedirect.d.ts
@@ -0,0 +1 @@
1
+ import{n as e,t}from"../setupRedirect-BTZPAp92.js";import{t as n}from"../useRedirectInfo-CSkKkjhg.js";import{t as r}from"../RedirectModal-BrOzOt-4.js";export{r as RedirectModal,e as setupDevServerRedirect,t as setupRedirect,n as useRedirectInfo};
@@ -33,4 +33,4 @@ interface RedirectPluginLocaleData {
33
33
  }
34
34
  //#endregion
35
35
  export { RedirectPluginLocaleData as t };
36
- //# sourceMappingURL=locales-CrXL-ZZP.d.ts.map
36
+ //# sourceMappingURL=locales-Z6zBEIHt.d.ts.map
@@ -1,5 +1,5 @@
1
- import { n as RedirectBehaviorOptions } from "../behavior-D5-7wmJ-.js";
2
- import { t as RedirectPluginLocaleData } from "../locales-CrXL-ZZP.js";
1
+ import { n as RedirectBehaviorOptions } from "../behavior-CskAbQua.js";
2
+ import { t as RedirectPluginLocaleData } from "../locales-Z6zBEIHt.js";
3
3
  import { App, LocaleConfig, PluginFunction } from "vuepress/core";
4
4
  import { PageFrontmatter } from "vuepress";
5
5
 
@@ -1,4 +1,4 @@
1
- import{t as e}from"../getRedirectHTML-C9SBJAfB.js";import{t}from"../normalizePath-DCapcto5.js";import{Logger as n,addViteSsrNoExternal as r,deepAssign as i,entries as a,fromEntries as o,getFullLocaleConfig as s,getModulePath as c,isArray as l,isFunction as u,isLinkAbsolute as d,isLinkHttp as f,isPlainObject as p,keys as m,removeEndingSlash as h,removeLeadingSlash as g}from"@vuepress/helper";import{createPage as _}from"vuepress/core";import{colors as v,fs as y,getDirname as b,path as x}from"vuepress/utils";const S=async e=>{e.pages.every(({path:e})=>e!==`/`)&&e.pages.push(await _(e,{path:`/`,frontmatter:{title:`Home`},content:`Redirecting to the correct locale...
1
+ import{t as e}from"../getRedirectHTML-C9SBJAfB.js";import{t}from"../normalizePath-NaIHZnk8.js";import{Logger as n,addViteSsrNoExternal as r,deepAssign as i,entries as a,fromEntries as o,getFullLocaleConfig as s,getModulePath as c,isArray as l,isFunction as u,isLinkAbsolute as d,isLinkHttp as f,isPlainObject as p,keys as m,removeEndingSlash as h,removeLeadingSlash as g}from"@vuepress/helper";import{createPage as _}from"vuepress/core";import{colors as v,fs as y,getDirname as b,path as x}from"vuepress/utils";const S=async e=>{e.pages.every(({path:e})=>e!==`/`)&&e.pages.push(await _(e,{path:`/`,frontmatter:{title:`Home`},content:`Redirecting to the correct locale...
2
2
  `}))},C=`@vuepress/plugin-redirect`,w=new n(C),T=({config:e,defaultBehavior:t,defaultLocale:n,localeFallback:r},i,a)=>`<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
@@ -1,2 +1,2 @@
1
1
  const e=/#.*$/u,t=(t,n=!1)=>(n?t.replace(e,``):t).replace(/\/(?:README\.md)?$/i,`/index.html`).replace(/(?:\.(?:md|html))?$/,`.html`);export{t};
2
- //# sourceMappingURL=normalizePath-DCapcto5.js.map
2
+ //# sourceMappingURL=normalizePath-NaIHZnk8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizePath-DCapcto5.js","names":[],"sources":["../src/shared/normalizePath.ts"],"sourcesContent":["const HASH_REGEXP = /#.*$/u\n\nexport const normalizePath = (path: string, removeHash = false): string =>\n (removeHash ? path.replace(HASH_REGEXP, '') : path)\n .replace(/\\/(?:README\\.md)?$/i, '/index.html')\n .replace(/(?:\\.(?:md|html))?$/, '.html')\n"],"mappings":"AAAA,MAAM,EAAc,QAEP,GAAiB,EAAc,EAAa,MACtD,EAAa,EAAK,QAAQ,EAAa,GAAG,CAAG,GAC3C,QAAQ,sBAAuB,cAAc,CAC7C,QAAQ,sBAAuB,QAAQ"}
1
+ {"version":3,"file":"normalizePath-NaIHZnk8.js","names":[],"sources":["../src/shared/normalizePath.ts"],"sourcesContent":["const HASH_REGEXP = /#.*$/u\n\nexport const normalizePath = (path: string, removeHash = false): string =>\n (removeHash ? path.replace(HASH_REGEXP, '') : path)\n .replace(/\\/(?:README\\.md)?$/i, '/index.html')\n .replace(/(?:\\.(?:md|html))?$/, '.html')\n"],"mappings":"AAAA,MAAM,EAAc,QAEP,GAAiB,EAAc,EAAa,MACtD,EAAa,EAAK,QAAQ,EAAa,GAAG,CAAG,GAC3C,QAAQ,sBAAuB,cAAc,CAC7C,QAAQ,sBAAuB,QAAQ"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./normalizePath-DCapcto5.js";import{r as t,t as n}from"./useRedirectInfo-BhfN7KrZ.js";import{usePreferredLanguages as r,watchImmediate as i}from"@vueuse/core";import{computed as a,onMounted as o}from"vue";import{useData as s,useRoute as c,useRouteLocale as l,useRoutePath as u,useRouter as d}from"vuepress/client";import{redirectMap as f}from"@temp/redirect/map.js";import{entries as p,isLinkHttp as m}from"@vuepress/helper/client";const h=({autoLocale:t,config:n,defaultBehavior:o,defaultLocale:s,localeFallback:h})=>{let g=Object.entries(n),_=r(),v=c(),y=d(),b=l(),x=u(),S=a(()=>b.value===`/`),C=()=>{let e=x.value,t=y.getRoutes(),n=s&&t.some(({path:t})=>t===e.replace(`/`,s))?s:t.find(({path:t})=>e.split(`/`).length>=3&&t===e.replace(/^\/[^/]+\//,`/`))?.path,r=null;findLanguage:for(let n of _.value)for(let[i,a]of g)if(a.includes(n)){if(h&&t.every(({path:t})=>t!==e.replace(`/`,t)))continue;r=i;break findLanguage}let i=n?v.fullPath.replace(`/`,n):null;if(r){let n=t.some(({path:t})=>e.replace(`/`,r)===t),a=v.fullPath.replace(`/`,r),s=n?a:o===`homepage`?r:o===`defaultLocale`&&i?i:a;y.replace(s)}else i?y.replace(i):x.value!==`/404.html`&&y.replace(`/404.html`)};i(x,n=>{for(let[t,r]of p(f))if(e(n.toLowerCase())===t.toLowerCase()){m(r)?window.open(r):y.replace(r);return}t&&S.value&&C()})},g=e=>{let{routeLocale:r,routePath:i}=s(),a=d(),c=n(e);o(()=>{c.value&&!t.value[r.value]&&(a.replace(i.value.replace(r.value,c.value.localePath)),t.value[r.value]=!0)})};export{h as n,g as t};
2
- //# sourceMappingURL=setupRedirect-DB0Ip2i-.js.map
1
+ import{t as e}from"./normalizePath-NaIHZnk8.js";import{r as t,t as n}from"./useRedirectInfo-CSkKkjhg.js";import{usePreferredLanguages as r,watchImmediate as i}from"@vueuse/core";import{computed as a,onMounted as o}from"vue";import{useData as s,useRoute as c,useRouteLocale as l,useRoutePath as u,useRouter as d}from"vuepress/client";import{redirectMap as f}from"@temp/redirect/map.js";import{entries as p,isLinkHttp as m}from"@vuepress/helper/client";const h=({autoLocale:t,config:n,defaultBehavior:o,defaultLocale:s,localeFallback:h})=>{let g=Object.entries(n),_=r(),v=c(),y=d(),b=l(),x=u(),S=a(()=>b.value===`/`),C=()=>{let e=x.value,t=y.getRoutes(),n=s&&t.some(({path:t})=>t===e.replace(`/`,s))?s:t.find(({path:t})=>e.split(`/`).length>=3&&t===e.replace(/^\/[^/]+\//,`/`))?.path,r=null;findLanguage:for(let n of _.value)for(let[i,a]of g)if(a.includes(n)){if(h&&t.every(({path:t})=>t!==e.replace(`/`,t)))continue;r=i;break findLanguage}let i=n?v.fullPath.replace(`/`,n):null;if(r){let n=t.some(({path:t})=>e.replace(`/`,r)===t),a=v.fullPath.replace(`/`,r),s=n?a:o===`homepage`?r:o===`defaultLocale`&&i?i:a;y.replace(s)}else i?y.replace(i):x.value!==`/404.html`&&y.replace(`/404.html`)};i(x,n=>{for(let[t,r]of p(f))if(e(n.toLowerCase())===t.toLowerCase()){m(r)?window.open(r):y.replace(r);return}t&&S.value&&C()})},g=e=>{let{routeLocale:r,routePath:i}=s(),a=d(),c=n(e);o(()=>{c.value&&!t.value[r.value]&&(a.replace(i.value.replace(r.value,c.value.localePath)),t.value[r.value]=!0)})};export{h as n,g as t};
2
+ //# sourceMappingURL=setupRedirect-BTZPAp92.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupRedirect-DB0Ip2i-.js","names":[],"sources":["../src/client/composables/setupDevServerRedirect.ts","../src/client/composables/setupRedirect.ts"],"sourcesContent":["import { redirectMap } from '@temp/redirect/map.js'\nimport { entries, isLinkHttp } from '@vuepress/helper/client'\nimport { usePreferredLanguages, watchImmediate } from '@vueuse/core'\nimport { computed } from 'vue'\nimport {\n useRoute,\n useRouteLocale,\n useRoutePath,\n useRouter,\n} from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { normalizePath } from '../../shared/index.js'\n\nexport const setupDevServerRedirect = ({\n autoLocale,\n config,\n defaultBehavior,\n defaultLocale: defaultLocalePath,\n localeFallback,\n}: RedirectBehaviorConfig): void => {\n const localeEntries = Object.entries(config)\n const languages = usePreferredLanguages()\n const route = useRoute()\n const router = useRouter()\n const routeLocale = useRouteLocale()\n const routePath = useRoutePath()\n\n const isRootLocale = computed(() => routeLocale.value === '/')\n\n const handleLocaleRedirect = (): void => {\n const routePathValue = routePath.value\n const routes = router.getRoutes()\n const defaultLocale =\n defaultLocalePath &&\n routes.some(\n ({ path }) => path === routePathValue.replace('/', defaultLocalePath),\n )\n ? defaultLocalePath\n : routes.find(\n ({ path }) =>\n routePathValue.split('/').length >= 3 &&\n path === routePathValue.replace(/^\\/[^/]+\\//, '/'),\n )?.path\n\n let matchedLocalePath: string | null = null\n\n // get matched locale\n // oxlint-disable-next-line no-labels\n findLanguage: for (const lang of languages.value) {\n for (const [localePath, langs] of localeEntries) {\n if (langs.includes(lang)) {\n if (\n localeFallback &&\n routes.every(\n ({ path }) => path !== routePathValue.replace('/', path),\n )\n )\n continue\n\n matchedLocalePath = localePath\n // oxlint-disable-next-line no-labels\n break findLanguage\n }\n }\n }\n\n // default link\n const defaultRoute = defaultLocale\n ? route.fullPath.replace('/', defaultLocale)\n : null\n\n // a locale matches\n if (matchedLocalePath) {\n const hasLocalePage = routes.some(\n ({ path }) => routePathValue.replace('/', matchedLocalePath) === path,\n )\n const localeRoute = route.fullPath.replace('/', matchedLocalePath)\n\n const redirectPath =\n // the locale page exists\n hasLocalePage\n ? localeRoute\n : // the page does not exist\n defaultBehavior === 'homepage'\n ? // locale homepage\n matchedLocalePath\n : defaultBehavior === 'defaultLocale' && defaultRoute\n ? // default locale page\n defaultRoute\n : // as is to get a 404 page of that locale\n localeRoute\n\n void router.replace(redirectPath)\n }\n // we have a default page\n else if (defaultRoute) {\n void router.replace(defaultRoute)\n } else if (routePath.value !== '/404.html') {\n void router.replace('/404.html')\n }\n }\n\n watchImmediate(routePath, (path) => {\n // handle redirects\n for (const [from, to] of entries(redirectMap)) {\n if (normalizePath(path.toLowerCase()) === from.toLowerCase()) {\n if (isLinkHttp(to)) window.open(to)\n else void router.replace(to)\n\n return\n }\n }\n\n if (autoLocale && isRootLocale.value) handleLocaleRedirect()\n })\n}\n","import { onMounted } from 'vue'\nimport { useData, useRouter } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { statusSessionStorage } from '../utils/index.js'\nimport { useRedirectInfo } from './useRedirectInfo.js'\n\nexport interface LocaleInfo {\n lang: string\n localePath: string\n}\n\nexport const setupRedirect = (behaviorConfig: RedirectBehaviorConfig): void => {\n const { routeLocale, routePath } = useData()\n const router = useRouter()\n const redirectInfo = useRedirectInfo(behaviorConfig)\n\n onMounted(() => {\n if (redirectInfo.value && !statusSessionStorage.value[routeLocale.value]) {\n void router.replace(\n routePath.value.replace(\n routeLocale.value,\n redirectInfo.value.localePath,\n ),\n )\n statusSessionStorage.value[routeLocale.value] = true\n }\n })\n}\n"],"mappings":"mcAaA,MAAa,GAA0B,CACrC,aACA,S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O,KAAK,EAAG,CACzB,EAAO,QAAQ,EAAG,CAE5B,OAIA,GAAc,EAAa,OAAO,GAAsB,EAC5D,ECvGS,EAAiB,GAAiD,CAC7E,GAAM,CAAE,cAAa,aAAc,GAAS,CACtC,EAAS,GAAW,CACpB,EAAe,EAAgB,EAAe,CAEpD,MAAgB,CACV,EAAa,OAAS,CAAC,EAAqB,MAAM,EAAY,SAC3D,EAAO,QACV,EAAU,MAAM,QACd,EAAY,MACZ,EAAa,MAAM,WACpB,CACF,CACD,EAAqB,MAAM,EAAY,OAAS,KAElD"}
1
+ {"version":3,"file":"setupRedirect-BTZPAp92.js","names":[],"sources":["../src/client/composables/setupDevServerRedirect.ts","../src/client/composables/setupRedirect.ts"],"sourcesContent":["import { redirectMap } from '@temp/redirect/map.js'\nimport { entries, isLinkHttp } from '@vuepress/helper/client'\nimport { usePreferredLanguages, watchImmediate } from '@vueuse/core'\nimport { computed } from 'vue'\nimport {\n useRoute,\n useRouteLocale,\n useRoutePath,\n useRouter,\n} from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { normalizePath } from '../../shared/index.js'\n\nexport const setupDevServerRedirect = ({\n autoLocale,\n config,\n defaultBehavior,\n defaultLocale: defaultLocalePath,\n localeFallback,\n}: RedirectBehaviorConfig): void => {\n const localeEntries = Object.entries(config)\n const languages = usePreferredLanguages()\n const route = useRoute()\n const router = useRouter()\n const routeLocale = useRouteLocale()\n const routePath = useRoutePath()\n\n const isRootLocale = computed(() => routeLocale.value === '/')\n\n const handleLocaleRedirect = (): void => {\n const routePathValue = routePath.value\n const routes = router.getRoutes()\n const defaultLocale =\n defaultLocalePath &&\n routes.some(\n ({ path }) => path === routePathValue.replace('/', defaultLocalePath),\n )\n ? defaultLocalePath\n : routes.find(\n ({ path }) =>\n routePathValue.split('/').length >= 3 &&\n path === routePathValue.replace(/^\\/[^/]+\\//, '/'),\n )?.path\n\n let matchedLocalePath: string | null = null\n\n // get matched locale\n // oxlint-disable-next-line no-labels\n findLanguage: for (const lang of languages.value) {\n for (const [localePath, langs] of localeEntries) {\n if (langs.includes(lang)) {\n if (\n localeFallback &&\n routes.every(\n ({ path }) => path !== routePathValue.replace('/', path),\n )\n )\n continue\n\n matchedLocalePath = localePath\n // oxlint-disable-next-line no-labels\n break findLanguage\n }\n }\n }\n\n // default link\n const defaultRoute = defaultLocale\n ? route.fullPath.replace('/', defaultLocale)\n : null\n\n // a locale matches\n if (matchedLocalePath) {\n const hasLocalePage = routes.some(\n ({ path }) => routePathValue.replace('/', matchedLocalePath) === path,\n )\n const localeRoute = route.fullPath.replace('/', matchedLocalePath)\n\n const redirectPath =\n // the locale page exists\n hasLocalePage\n ? localeRoute\n : // the page does not exist\n defaultBehavior === 'homepage'\n ? // locale homepage\n matchedLocalePath\n : defaultBehavior === 'defaultLocale' && defaultRoute\n ? // default locale page\n defaultRoute\n : // as is to get a 404 page of that locale\n localeRoute\n\n void router.replace(redirectPath)\n }\n // we have a default page\n else if (defaultRoute) {\n void router.replace(defaultRoute)\n } else if (routePath.value !== '/404.html') {\n void router.replace('/404.html')\n }\n }\n\n watchImmediate(routePath, (path) => {\n // handle redirects\n for (const [from, to] of entries(redirectMap)) {\n if (normalizePath(path.toLowerCase()) === from.toLowerCase()) {\n if (isLinkHttp(to)) window.open(to)\n else void router.replace(to)\n\n return\n }\n }\n\n if (autoLocale && isRootLocale.value) handleLocaleRedirect()\n })\n}\n","import { onMounted } from 'vue'\nimport { useData, useRouter } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { statusSessionStorage } from '../utils/index.js'\nimport { useRedirectInfo } from './useRedirectInfo.js'\n\nexport interface LocaleInfo {\n lang: string\n localePath: string\n}\n\nexport const setupRedirect = (behaviorConfig: RedirectBehaviorConfig): void => {\n const { routeLocale, routePath } = useData()\n const router = useRouter()\n const redirectInfo = useRedirectInfo(behaviorConfig)\n\n onMounted(() => {\n if (redirectInfo.value && !statusSessionStorage.value[routeLocale.value]) {\n void router.replace(\n routePath.value.replace(\n routeLocale.value,\n redirectInfo.value.localePath,\n ),\n )\n statusSessionStorage.value[routeLocale.value] = true\n }\n })\n}\n"],"mappings":"mcAaA,MAAa,GAA0B,CACrC,aACA,SACA,kBACA,cAAe,EACf,oBACkC,CAClC,IAAM,EAAgB,OAAO,QAAQ,EAAO,CACtC,EAAY,GAAuB,CACnC,EAAQ,GAAU,CAClB,EAAS,GAAW,CACpB,EAAc,GAAgB,CAC9B,EAAY,GAAc,CAE1B,EAAe,MAAe,EAAY,QAAU,IAAI,CAExD,MAAmC,CACvC,IAAM,EAAiB,EAAU,MAC3B,EAAS,EAAO,WAAW,CAC3B,EACJ,GACA,EAAO,MACJ,CAAE,UAAW,IAAS,EAAe,QAAQ,IAAK,EAAkB,CACtE,CACG,EACA,EAAO,MACJ,CAAE,UACD,EAAe,MAAM,IAAI,CAAC,QAAU,GACpC,IAAS,EAAe,QAAQ,aAAc,IAAI,CACrD,EAAE,KAEL,EAAmC,KAIvC,aAAc,IAAK,IAAM,KAAQ,EAAU,MACzC,IAAK,GAAM,CAAC,EAAY,KAAU,EAChC,GAAI,EAAM,SAAS,EAAK,CAAE,CACxB,GACE,GACA,EAAO,OACJ,CAAE,UAAW,IAAS,EAAe,QAAQ,IAAK,EAAK,CACzD,CAED,SAEF,EAAoB,EAEpB,MAAM,aAMZ,IAAM,EAAe,EACjB,EAAM,SAAS,QAAQ,IAAK,EAAc,CAC1C,KAGJ,GAAI,EAAmB,CACrB,IAAM,EAAgB,EAAO,MAC1B,CAAE,UAAW,EAAe,QAAQ,IAAK,EAAkB,GAAK,EAClE,CACK,EAAc,EAAM,SAAS,QAAQ,IAAK,EAAkB,CAE5D,EAEJ,EACI,EAEA,IAAoB,WAElB,EACA,IAAoB,iBAAmB,EAErC,EAEA,EAEL,EAAO,QAAQ,EAAa,MAG1B,EACF,EAAO,QAAQ,EAAa,CACxB,EAAU,QAAU,aACxB,EAAO,QAAQ,YAAY,EAIpC,EAAe,EAAY,GAAS,CAElC,IAAK,GAAM,CAAC,EAAM,KAAO,EAAQ,EAAY,CAC3C,GAAI,EAAc,EAAK,aAAa,CAAC,GAAK,EAAK,aAAa,CAAE,CACxD,EAAW,EAAG,CAAE,OAAO,KAAK,EAAG,CACzB,EAAO,QAAQ,EAAG,CAE5B,OAIA,GAAc,EAAa,OAAO,GAAsB,EAC5D,ECvGS,EAAiB,GAAiD,CAC7E,GAAM,CAAE,cAAa,aAAc,GAAS,CACtC,EAAS,GAAW,CACpB,EAAe,EAAgB,EAAe,CAEpD,MAAgB,CACV,EAAa,OAAS,CAAC,EAAqB,MAAM,EAAY,SAC3D,EAAO,QACV,EAAU,MAAM,QACd,EAAY,MACZ,EAAa,MAAM,WACpB,CACF,CACD,EAAqB,MAAM,EAAY,OAAS,KAElD"}
@@ -1,2 +1,2 @@
1
1
  import{useLocalStorage as e,usePreferredLanguages as t,useSessionStorage as n}from"@vueuse/core";import{computed as r}from"vue";import{useRouteLocale as i}from"vuepress/client";import{entries as a}from"@vuepress/helper/client";const o=`VUEPRESS_REDIRECT_STATUS`,s=e(o,{}),c=n(o,{}),l=e=>{let n=t(),o=i(),s=a(e.config);return r(()=>{if(s.some(([e])=>o.value===e)){for(let e of n.value)for(let[t,n]of s)if(n.includes(e))return t===o.value?null:{lang:e,localePath:t}}return null})};export{s as n,c as r,l as t};
2
- //# sourceMappingURL=useRedirectInfo-BhfN7KrZ.js.map
2
+ //# sourceMappingURL=useRedirectInfo-CSkKkjhg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRedirectInfo-BhfN7KrZ.js","names":[],"sources":["../src/client/utils/storage.ts","../src/client/composables/useRedirectInfo.ts"],"sourcesContent":["import { useLocalStorage, useSessionStorage } from '@vueuse/core'\n\nconst REDIRECT_STORAGE_KEY = 'VUEPRESS_REDIRECT_STATUS'\n\nexport const statusLocalStorage = useLocalStorage<Record<string, boolean>>(\n REDIRECT_STORAGE_KEY,\n {},\n)\n\nexport const statusSessionStorage = useSessionStorage<Record<string, boolean>>(\n REDIRECT_STORAGE_KEY,\n {},\n)\n","import { entries } from '@vuepress/helper/client'\nimport { usePreferredLanguages } from '@vueuse/core'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { useRouteLocale } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\n\nexport interface RedirectInfo {\n lang: string\n localePath: string\n}\n\nexport const useRedirectInfo = (\n behaviorConfig: RedirectBehaviorConfig,\n): ComputedRef<RedirectInfo | null> => {\n const languages = usePreferredLanguages()\n const routeLocale = useRouteLocale()\n\n const localeEntries = entries(behaviorConfig.config)\n\n return computed(() => {\n if (localeEntries.some(([key]) => routeLocale.value === key)) {\n for (const language of languages.value) {\n for (const [localePath, langs] of localeEntries) {\n if (langs.includes(language)) {\n // oxlint-disable-next-line max-depth\n if (localePath === routeLocale.value) return null\n\n return {\n lang: language,\n localePath,\n }\n }\n }\n }\n }\n\n return null\n })\n}\n"],"mappings":"mOAEA,MAAM,EAAuB,2BAEhB,EAAqB,EAChC,EACA,EAAE,CACH,CAEY,EAAuB,EAClC,EACA,EAAE,CACH,CCAY,EACX,GACqC,CACrC,IAAM,EAAY,GAAuB,CACnC,EAAc,GAAgB,CAE9B,EAAgB,EAAQ,EAAe,OAAO,CAEpD,OAAO,MAAe,CACpB,GAAI,EAAc,MAAM,CAAC,KAAS,EAAY,QAAU,EAAI,MACrD,IAAM,KAAY,EAAU,MAC/B,IAAK,GAAM,CAAC,EAAY,KAAU,EAChC,GAAI,EAAM,SAAS,EAAS,CAI1B,OAFI,IAAe,EAAY,MAAc,KAEtC,CACL,KAAM,EACN,aACD,CAMT,OAAO,MACP"}
1
+ {"version":3,"file":"useRedirectInfo-CSkKkjhg.js","names":[],"sources":["../src/client/utils/storage.ts","../src/client/composables/useRedirectInfo.ts"],"sourcesContent":["import { useLocalStorage, useSessionStorage } from '@vueuse/core'\n\nconst REDIRECT_STORAGE_KEY = 'VUEPRESS_REDIRECT_STATUS'\n\nexport const statusLocalStorage = useLocalStorage<Record<string, boolean>>(\n REDIRECT_STORAGE_KEY,\n {},\n)\n\nexport const statusSessionStorage = useSessionStorage<Record<string, boolean>>(\n REDIRECT_STORAGE_KEY,\n {},\n)\n","import { entries } from '@vuepress/helper/client'\nimport { usePreferredLanguages } from '@vueuse/core'\nimport type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport { useRouteLocale } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\n\nexport interface RedirectInfo {\n lang: string\n localePath: string\n}\n\nexport const useRedirectInfo = (\n behaviorConfig: RedirectBehaviorConfig,\n): ComputedRef<RedirectInfo | null> => {\n const languages = usePreferredLanguages()\n const routeLocale = useRouteLocale()\n\n const localeEntries = entries(behaviorConfig.config)\n\n return computed(() => {\n if (localeEntries.some(([key]) => routeLocale.value === key)) {\n for (const language of languages.value) {\n for (const [localePath, langs] of localeEntries) {\n if (langs.includes(language)) {\n // oxlint-disable-next-line max-depth\n if (localePath === routeLocale.value) return null\n\n return {\n lang: language,\n localePath,\n }\n }\n }\n }\n }\n\n return null\n })\n}\n"],"mappings":"mOAEA,MAAM,EAAuB,2BAEhB,EAAqB,EAChC,EACA,EAAE,CACH,CAEY,EAAuB,EAClC,EACA,EAAE,CACH,CCAY,EACX,GACqC,CACrC,IAAM,EAAY,GAAuB,CACnC,EAAc,GAAgB,CAE9B,EAAgB,EAAQ,EAAe,OAAO,CAEpD,OAAO,MAAe,CACpB,GAAI,EAAc,MAAM,CAAC,KAAS,EAAY,QAAU,EAAI,MACrD,IAAM,KAAY,EAAU,MAC/B,IAAK,GAAM,CAAC,EAAY,KAAU,EAChC,GAAI,EAAM,SAAS,EAAS,CAI1B,OAFI,IAAe,EAAY,MAAc,KAEtC,CACL,KAAM,EACN,aACD,CAMT,OAAO,MACP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-redirect",
3
- "version": "2.0.0-rc.124",
3
+ "version": "2.0.0-rc.125",
4
4
  "description": "VuePress plugin - redirect",
5
5
  "keywords": [
6
6
  "plugin",
@@ -24,23 +24,23 @@
24
24
  "directory": "plugins/tools/plugin-redirect"
25
25
  },
26
26
  "bin": {
27
- "vp-redirect": "./lib/cli/index.js"
27
+ "vp-redirect": "./dist/cli/index.js"
28
28
  },
29
29
  "files": [
30
- "lib"
30
+ "dist"
31
31
  ],
32
32
  "type": "module",
33
33
  "sideEffects": [
34
- "./lib/client/styles/**/*.css"
34
+ "./dist/client/styles/**/*.css"
35
35
  ],
36
36
  "exports": {
37
37
  ".": {
38
- "types": "./lib/node/index.d.ts",
39
- "default": "./lib/node/index.js"
38
+ "types": "./dist/node/index.d.ts",
39
+ "default": "./dist/node/index.js"
40
40
  },
41
41
  "./client": {
42
- "types": "./lib/client/index.d.ts",
43
- "default": "./lib/client/index.js"
42
+ "types": "./dist/client/index.d.ts",
43
+ "default": "./dist/client/index.js"
44
44
  },
45
45
  "./package.json": "./package.json"
46
46
  },
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@vuepress/helper": "2.0.0-rc.124",
51
+ "@vuepress/helper": "2.0.0-rc.125",
52
52
  "@vueuse/core": "^14.2.1",
53
53
  "commander": "^14.0.3",
54
54
  "vue": "^3.5.29"
@@ -56,5 +56,5 @@
56
56
  "peerDependencies": {
57
57
  "vuepress": "2.0.0-rc.26"
58
58
  },
59
- "gitHead": "f17e7479b1ef3c06814b6107df9188ba351702da"
59
+ "gitHead": "58e660bb7138f1883e5440a08903d09cdbabcdc8"
60
60
  }
@@ -1,2 +0,0 @@
1
- import { t as _default } from "../../RedirectModal-DopLrY65.js";
2
- export { _default as default };
@@ -1,2 +0,0 @@
1
- import{n as e,r as t,t as n}from"../../useRedirectInfo-BhfN7KrZ.js";import{useScrollLock as r}from"@vueuse/core";import{TransitionGroup as i,computed as a,defineComponent as o,h as s,nextTick as c,onBeforeUnmount as l,onMounted as u,ref as d,watch as f}from"vue";import{useData as p,useRouter as m}from"vuepress/client";import"@vuepress/helper/transition/fade-in-scale-up.css";import"../styles/redirect-modal.css";var h=o({name:`RedirectModal`,props:{config:{type:Object,required:!0},locales:{type:Object,required:!0}},setup(o){let h=m(),{routeLocale:g,routePath:_}=p(),v=n(o.config),y=d(),b=r(y),x=d(!1),S=a(()=>{if(!v.value)return null;let{lang:e,localePath:t}=v.value,n=[o.locales[t],o.locales[g.value]];return{hint:n.map(({hint:t})=>t.replace(`$1`,e)),switch:n.map(({switch:t})=>t.replace(`$1`,e)).join(` / `),cancel:n.map(({cancel:e})=>e).join(` / `),remember:n.map(({remember:e})=>e).join(` / `)}}),C=()=>{t.value[g.value]=!0,x.value&&(e.value[g.value]=!0),b.value=!1};return f(_,()=>{b.value=!1}),u(async()=>{y.value=document.body,await c(),v.value&&!t.value[g.value]&&!e.value[g.value]&&(b.value=!0)}),l(()=>{b.value=!1}),()=>s(i,{name:`fade-in-scale-up`},()=>b.value?s(`div`,{key:`mask`,class:`redirect-modal-mask`},s(`div`,{key:`popup`,class:`redirect-modal-wrapper`},[s(`div`,{class:`redirect-modal-content`},S.value?.hint.map(e=>s(`p`,e))),s(`div`,{class:`redirect-modal-hint`},[s(`input`,{id:`remember-redirect`,type:`checkbox`,value:x.value,onChange:()=>{x.value=!x.value}}),s(`label`,{for:`remember-redirect`},S.value?.remember)]),s(`button`,{type:`button`,class:`redirect-modal-action primary`,onClick:()=>{C(),h.replace(_.value.replace(g.value,v.value.localePath))}},S.value?.switch),s(`button`,{type:`button`,class:`redirect-modal-action`,onClick:()=>{C()}},S.value?.cancel)])):null)}});export{h as default};
2
- //# sourceMappingURL=RedirectModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedirectModal.js","names":[],"sources":["../../../src/client/components/RedirectModal.ts"],"sourcesContent":["import { useScrollLock } from '@vueuse/core'\nimport type { PropType, VNode } from 'vue'\nimport {\n TransitionGroup,\n computed,\n defineComponent,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n} from 'vue'\nimport { useData, useRouter } from 'vuepress/client'\nimport type { RedirectBehaviorConfig } from '../../shared/index.js'\nimport { useRedirectInfo } from '../composables/index.js'\nimport type { RedirectPluginLocaleConfig } from '../types.js'\nimport { statusLocalStorage, statusSessionStorage } from '../utils/index.js'\n\nimport '@vuepress/helper/transition/fade-in-scale-up.css'\nimport '../styles/redirect-modal.css'\n\nexport default defineComponent({\n name: 'RedirectModal',\n\n props: {\n config: {\n type: Object as PropType<RedirectBehaviorConfig>,\n required: true,\n },\n\n locales: {\n type: Object as PropType<RedirectPluginLocaleConfig>,\n required: true,\n },\n },\n\n setup(props) {\n const router = useRouter()\n const { routeLocale, routePath } = useData()\n const redirectInfo = useRedirectInfo(props.config)\n\n const body = ref<HTMLElement>()\n // lock body scroll when modal is displayed\n const showModal = useScrollLock(body)\n const shouldRemember = ref(false)\n\n const locale = computed(() => {\n if (!redirectInfo.value) return null\n\n const { lang, localePath } = redirectInfo.value\n const locales = [\n props.locales[localePath],\n props.locales[routeLocale.value],\n ]\n\n return {\n hint: locales.map(({ hint }) => hint.replace('$1', lang)),\n switch: locales\n .map(({ switch: switchText }) => switchText.replace('$1', lang))\n .join(' / '),\n cancel: locales.map(({ cancel }) => cancel).join(' / '),\n remember: locales.map(({ remember }) => remember).join(' / '),\n }\n })\n\n const updateState = (): void => {\n statusSessionStorage.value[routeLocale.value] = true\n if (shouldRemember.value)\n statusLocalStorage.value[routeLocale.value] = true\n\n showModal.value = false\n }\n\n watch(routePath, () => {\n showModal.value = false\n })\n\n onMounted(async () => {\n body.value = document.body\n\n await nextTick()\n\n if (\n redirectInfo.value &&\n !statusSessionStorage.value[routeLocale.value] &&\n !statusLocalStorage.value[routeLocale.value]\n )\n showModal.value = true\n })\n\n onBeforeUnmount(() => {\n showModal.value = false\n })\n\n return (): VNode | null =>\n h(TransitionGroup, { name: 'fade-in-scale-up' }, () =>\n showModal.value\n ? h(\n 'div',\n { key: 'mask', class: 'redirect-modal-mask' },\n h(\n 'div',\n {\n key: 'popup',\n class: 'redirect-modal-wrapper',\n },\n [\n h(\n 'div',\n { class: 'redirect-modal-content' },\n locale.value?.hint.map((text) => h('p', text)),\n ),\n h('div', { class: 'redirect-modal-hint' }, [\n h('input', {\n id: 'remember-redirect',\n type: 'checkbox',\n value: shouldRemember.value,\n onChange: () => {\n shouldRemember.value = !shouldRemember.value\n },\n }),\n h(\n 'label',\n { for: 'remember-redirect' },\n locale.value?.remember,\n ),\n ]),\n h(\n 'button',\n {\n type: 'button',\n class: 'redirect-modal-action primary',\n onClick: () => {\n updateState()\n void router.replace(\n routePath.value.replace(\n routeLocale.value,\n redirectInfo.value!.localePath,\n ),\n )\n },\n },\n locale.value?.switch,\n ),\n h(\n 'button',\n {\n type: 'button',\n class: 'redirect-modal-action',\n onClick: () => {\n updateState()\n },\n },\n locale.value?.cancel,\n ),\n ],\n ),\n )\n : null,\n )\n },\n})\n"],"mappings":"8ZAsBA,IAAA,EAAe,EAAgB,CAC7B,KAAM,gBAEN,MAAO,CACL,OAAQ,CACN,KAAM,OACN,SAAU,GACX,CAED,QAAS,CACP,KAAM,OACN,SAAU,GACX,CACF,CAED,MAAM,EAAO,CACX,IAAM,EAAS,GAAW,CACpB,CAAE,cAAa,aAAc,GAAS,CACtC,EAAe,EAAgB,EAAM,OAAO,CAE5C,EAAO,GAAkB,CAEzB,EAAY,EAAc,EAAK,CAC/B,EAAiB,EAAI,GAAM,CAE3B,EAAS,MAAe,CAC5B,GAAI,CAAC,EAAa,MAAO,OAAO,KAEhC,GAAM,CAAE,OAAM,cAAe,EAAa,MACpC,EAAU,CACd,EAAM,QAAQ,GACd,EAAM,QAAQ,EAAY,OAC3B,CAED,MAAO,CACL,KAAM,EAAQ,KAAK,CAAE,UAAW,EAAK,QAAQ,KAAM,EAAK,CAAC,CACzD,OAAQ,EACL,KAAK,CAAE,OAAQ,KAAiB,EAAW,QAAQ,KAAM,EAAK,CAAC,CAC/D,KAAK,MAAM,CACd,O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CACD,KACL,EAEN,CAAC"}
@@ -1 +0,0 @@
1
- import{n as e,t}from"../setupRedirect-DB0Ip2i-.js";import{t as n}from"../useRedirectInfo-BhfN7KrZ.js";import r from"./components/RedirectModal.js";export{r as RedirectModal,e as setupDevServerRedirect,t as setupRedirect,n as useRedirectInfo};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes