@tarojs/runtime 4.0.0 → 4.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { location } from '../bom/window.js';
1
+ import { taroLocationProvider } from '../bom/window.js';
2
2
 
3
3
  // export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
4
4
  // export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
@@ -15,8 +15,8 @@ const getHomePage = (path = '', basename = '', customRoutes = {}, entryPagePath
15
15
  };
16
16
  const getCurrentPage = (routerMode = 'hash', basename = '/') => {
17
17
  const pagePath = routerMode === 'hash'
18
- ? location.hash.slice(1).split('?')[0]
19
- : location.pathname;
18
+ ? taroLocationProvider.hash.slice(1).split('?')[0]
19
+ : taroLocationProvider.pathname;
20
20
  return addLeadingSlash(stripBasename(pagePath, basename));
21
21
  };
22
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sources":["../../src/utils/router.ts"],"sourcesContent":["import { location } from '../bom/window'\n\n// export const removeLeadingSlash = (str = '') => str.replace(/^\\.?\\//, '')\n// export const removeTrailingSearch = (str = '') => str.replace(/\\?[\\s\\S]*$/, '')\nexport const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url)\n\nexport const hasBasename = (path = '', prefix = '') =>\n new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path) || path === prefix\n\nexport const stripBasename = (path = '', prefix = '') =>\n hasBasename(path, prefix) ? path.substring(prefix.length) : path\n\nexport const stripTrailing = (str = '') => str.replace(/[?#][\\s\\S]*$/, '')\n\nexport const stripSuffix = (path = '', suffix = '') =>\n path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path\n\nexport const getHomePage = (path = '', basename = '', customRoutes: Record<string, string | string[]> = {}, entryPagePath = '') => {\n const routePath = addLeadingSlash(stripBasename(path, basename))\n const alias = Object.entries(customRoutes).find(\n ([key]) => key === routePath\n )?.[1] || routePath\n return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename\n}\n\nexport const getCurrentPage = (routerMode = 'hash', basename = '/') => {\n const pagePath = routerMode === 'hash'\n ? location.hash.slice(1).split('?')[0]\n : location.pathname\n return addLeadingSlash(stripBasename(pagePath, basename))\n}\n"],"names":[],"mappings":";;AAEA;AACA;AACO,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAC;AAE/E,MAAM,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,GAAG,eAAe,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,OAAM;AAElE,MAAA,aAAa,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAClD,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;AAErD,MAAA,aAAa,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,EAAC;AAE7D,MAAA,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;MAElE,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,eAAkD,EAAE,EAAE,aAAa,GAAG,EAAE,KAAI;;IAChI,MAAM,SAAS,GAAG,eAAe,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAChE,IAAA,MAAM,KAAK,GAAG,CAAA,CAAA,EAAA,GAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAC7C,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,SAAS,CAC7B,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,KAAI,SAAS,CAAA;IACnB,OAAO,aAAa,KAAK,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAA;AACpF,EAAC;AAEM,MAAM,cAAc,GAAG,CAAC,UAAU,GAAG,MAAM,EAAE,QAAQ,GAAG,GAAG,KAAI;AACpE,IAAA,MAAM,QAAQ,GAAG,UAAU,KAAK,MAAM;AACpC,UAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtC,UAAE,QAAQ,CAAC,QAAQ,CAAA;IACrB,OAAO,eAAe,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC3D;;;;"}
1
+ {"version":3,"file":"router.js","sources":["../../src/utils/router.ts"],"sourcesContent":["import { taroLocationProvider as location } from '../bom/window'\n\n// export const removeLeadingSlash = (str = '') => str.replace(/^\\.?\\//, '')\n// export const removeTrailingSearch = (str = '') => str.replace(/\\?[\\s\\S]*$/, '')\nexport const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url)\n\nexport const hasBasename = (path = '', prefix = '') =>\n new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path) || path === prefix\n\nexport const stripBasename = (path = '', prefix = '') =>\n hasBasename(path, prefix) ? path.substring(prefix.length) : path\n\nexport const stripTrailing = (str = '') => str.replace(/[?#][\\s\\S]*$/, '')\n\nexport const stripSuffix = (path = '', suffix = '') =>\n path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path\n\nexport const getHomePage = (path = '', basename = '', customRoutes: Record<string, string | string[]> = {}, entryPagePath = '') => {\n const routePath = addLeadingSlash(stripBasename(path, basename))\n const alias = Object.entries(customRoutes).find(\n ([key]) => key === routePath\n )?.[1] || routePath\n return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename\n}\n\nexport const getCurrentPage = (routerMode = 'hash', basename = '/') => {\n const pagePath = routerMode === 'hash'\n ? location.hash.slice(1).split('?')[0]\n : location.pathname\n return addLeadingSlash(stripBasename(pagePath, basename))\n}\n"],"names":["location"],"mappings":";;AAEA;AACA;AACO,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAC;AAE/E,MAAM,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,GAAG,eAAe,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,OAAM;AAElE,MAAA,aAAa,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAClD,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;AAErD,MAAA,aAAa,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,EAAC;AAE7D,MAAA,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;MAElE,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,eAAkD,EAAE,EAAE,aAAa,GAAG,EAAE,KAAI;;IAChI,MAAM,SAAS,GAAG,eAAe,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAChE,IAAA,MAAM,KAAK,GAAG,CAAA,CAAA,EAAA,GAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAC7C,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,SAAS,CAC7B,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,KAAI,SAAS,CAAA;IACnB,OAAO,aAAa,KAAK,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAA;AACpF,EAAC;AAEM,MAAM,cAAc,GAAG,CAAC,UAAU,GAAG,MAAM,EAAE,QAAQ,GAAG,GAAG,KAAI;AACpE,IAAA,MAAM,QAAQ,GAAG,UAAU,KAAK,MAAM;AACpC,UAAEA,oBAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtC,UAAEA,oBAAQ,CAAC,QAAQ,CAAA;IACrB,OAAO,eAAe,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC3D;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/runtime",
3
- "version": "4.0.0",
3
+ "version": "4.0.1-alpha.1",
4
4
  "description": "taro runtime for mini apps.",
5
5
  "author": "O2Team",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "tslib": "^2.6.2",
25
- "@tarojs/shared": "4.0.0"
25
+ "@tarojs/shared": "4.0.1-alpha.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^18.2.79",