@hitachivantara/app-shell-navigation 1.2.1 → 1.2.3

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 +1 @@
1
- {"version":3,"file":"useNavigation.js","sources":["../../../../src/lib/hooks/useNavigation.tsx"],"sourcesContent":["import { useCallback, useContext, useMemo, useRef } from \"react\";\nimport { Path, useNavigate } from \"react-router-dom\";\n\nimport {\n HvAppShellViewContext,\n HvAppShellViewsConfig,\n useHvAppShellConfig\n} from \"@hitachivantara/app-shell-shared\";\n\nimport { NavigationOptions, To, ViewDestination } from \"../types\";\nimport compileHref from \"../utils/navigationUtil\";\nimport useHvLocation from \"./useLocation\";\n\nconst isViewDestination = (to: To): to is ViewDestination => {\n return (to as ViewDestination).viewBundle !== undefined;\n};\n\nconst isPathDestination = (to: To): to is Partial<Path> => {\n return typeof to !== \"string\" && !isViewDestination(to);\n};\n\ntype ViewSearchMode = \"auto\" | \"top\";\n\ninterface GetViewRouteOptions {\n mode?: ViewSearchMode;\n}\n\ntype NavigateOptions = GetViewRouteOptions & Partial<NavigationOptions>;\n\nfunction getActiveViewRoute(\n activeViews: HvAppShellViewsConfig[],\n depth?: number\n): string {\n return `/${activeViews\n .map(view => view.route.substring(1))\n .slice(0, depth ?? activeViews.length)\n .filter(route => route !== \"\") // remove index routes\n .join(\"/\")}`;\n}\n\nfunction isSameBundle(\n v: HvAppShellViewsConfig,\n bundle: string,\n appId: string | undefined\n) {\n return (\n v.bundle === `${bundle}` ||\n v.bundle === `${bundle}.js` ||\n v.bundle === `${appId}/${bundle}.js` ||\n v.bundle === `${appId}/${bundle}`\n );\n}\n\nconst useNavigation = () => {\n const config = useHvAppShellConfig();\n const flattenViews = useMemo(() => {\n const flatten = (views: HvAppShellViewsConfig[], base = \"\") => {\n return views.reduce<HvAppShellViewsConfig[]>((acc, view) => {\n // concatenate base with view route\n const route = `${base}${view.route}` as HvAppShellViewsConfig[\"route\"];\n acc.push({ ...view, route });\n if (view.views != null) {\n acc.push(...flatten(view.views, route));\n }\n return acc;\n }, []);\n };\n return flatten(config.mainPanel?.views ?? []);\n }, [config.mainPanel?.views]);\n\n const viewContext = useContext(HvAppShellViewContext);\n const navigateReactRouter = useNavigate();\n\n // the returned navigate and getViewRoute functions need to be stable\n // regardless of the location change, but we need to use the most recent location\n // in the getViewRoute algorithm, so we use a ref to store the location\n const location = useHvLocation();\n const locationRef = useRef(location);\n locationRef.current = location;\n\n /**\n * Utility to search for the route of a View on the App Shell configuration.\n *\n * The search can be performed in different modes:\n * - \"auto\": Searches within views whose route is a subpath of the current active view, progressively going up path segments until a match is found.\n * - \"top\": Finds the view closest to the root, i.e. with the least number of path segments.\n *\n * If multiple views match the search criteria, the function returns the one that appears first in the App Shell configuration.\n *\n * @param viewBundleDir The application view bundle directory name and optional route parameters.\n * @param mode The search mode to use. Defaults to \"auto\".\n *\n * @returns The compiled route or undefined if none was found.\n */\n const getViewRoute = useCallback(\n (\n viewBundleDir: string | ViewDestination,\n { mode = \"auto\" }: GetViewRouteOptions = {}\n ): string | undefined => {\n let viewBundle;\n let pathParams;\n let search;\n let hash;\n\n if (isViewDestination(viewBundleDir)) {\n ({ viewBundle, pathParams, search, hash } = viewBundleDir);\n } else {\n viewBundle = viewBundleDir;\n }\n const bundleWithReplacedPlaceholders = viewBundle.replace(/\\$/, \"_\");\n\n let appId: string | undefined;\n let bundle: string;\n\n // local navigation\n if (bundleWithReplacedPlaceholders.startsWith(\"/\")) {\n appId = viewContext?.id;\n bundle = bundleWithReplacedPlaceholders.substring(1);\n } else {\n bundle = bundleWithReplacedPlaceholders;\n }\n\n let activeViews: HvAppShellViewsConfig[] = [];\n if (mode !== \"top\") {\n activeViews = locationRef.current.views;\n }\n\n let route: string | undefined;\n\n const matchingViews = flattenViews\n .filter(v => isSameBundle(v, bundle, appId))\n .sort((a, b) => {\n const aSlashCount = (a.route.match(/\\//g) ?? []).length;\n const bSlashCount = (b.route.match(/\\//g) ?? []).length;\n return aSlashCount - bSlashCount;\n });\n\n if (matchingViews.length > 0) {\n if (mode === \"top\" || matchingViews.length === 1) {\n // no need for search algorithms if there is only one matching view\n route = matchingViews[0].route;\n } else if (mode === \"auto\") {\n const activeViewRoute = getActiveViewRoute(activeViews);\n\n let path = `${activeViewRoute}/`;\n while (route == null) {\n const innerPath = path;\n route = matchingViews.find(v => v.route.startsWith(innerPath))\n ?.route;\n\n // remove last path segment, e.g. /path/segment/ -> /path/ -> /\n path = path.replace(/\\/[^/]*\\/?$/, \"/\");\n\n if (path === \"\") {\n break;\n }\n }\n }\n }\n\n return route\n ? `${compileHref(route, pathParams)}${search ?? \"\"}${hash ?? \"\"}`\n : undefined;\n },\n [flattenViews, viewContext?.id]\n );\n\n /**\n * Performs navigation, through 'history.push' or 'history.replace', for the given destination with the passed navigation options.\n * @see https://reactrouter.com/hooks/use-navigate\n *\n * @param to The destination of the navigation. For ViewDestination type see {@link ViewDestination}.\n * @param options The navigation options:\n * - mode: The search mode to use when searching for the route of a View on the App Shell configuration. Defaults to \"auto\".\n * - replace: If true, the navigation will replace the current entry in the history stack instead of adding a new one.\n * - state: State to associate to the location.\n */\n const navigate = useCallback(\n (to: To, options?: NavigateOptions) => {\n let path;\n if (isPathDestination(to)) {\n path = to;\n } else {\n const route = getViewRoute(to, { mode: options?.mode });\n\n if (route == null) {\n if (typeof to === \"string\") {\n path = to;\n } else {\n // If route for given module is not found on the App Shell configuration file, do nothing.\n console.warn(\n `Navigate request to a non existing path [${to.viewBundle}]. Skipping`\n );\n return;\n }\n } else {\n path = route;\n }\n }\n\n let navigateOptions: NavigateOptions | undefined;\n if (options != null) {\n if (options.mode == null) {\n navigateOptions = options;\n } else {\n navigateOptions = { ...options };\n delete navigateOptions.mode;\n if (Object.keys(navigateOptions).length === 0) {\n navigateOptions = undefined;\n }\n }\n }\n\n navigateReactRouter(path, navigateOptions);\n },\n [getViewRoute, navigateReactRouter]\n );\n\n return { getViewRoute, navigate };\n};\n\nexport default useNavigation;\n"],"names":["isViewDestination","to","viewBundle","undefined","isPathDestination","getActiveViewRoute","activeViews","depth","map","view","route","substring","slice","length","filter","join","isSameBundle","v","bundle","appId","useNavigation","config","useHvAppShellConfig","flattenViews","useMemo","flatten","views","base","reduce","acc","push","mainPanel","viewContext","useContext","HvAppShellViewContext","navigateReactRouter","useNavigate","location","useHvLocation","locationRef","useRef","current","getViewRoute","useCallback","viewBundleDir","mode","pathParams","search","hash","bundleWithReplacedPlaceholders","replace","startsWith","id","matchingViews","sort","a","b","aSlashCount","match","bSlashCount","path","innerPath","find","compileHref","navigate","options","console","warn","navigateOptions","Object","keys","useNavigation$1"],"mappings":";;;;;AAaA,MAAMA,IAAoBA,CAACC,MACjBA,EAAuBC,eAAeC,QAG1CC,IAAoBA,CAACH,MAClB,OAAOA,KAAO,YAAY,CAACD,EAAkBC,CAAE;AAWxD,SAASI,EACPC,GACAC,GACQ;AACA,SAAA,IAAGD,EACRE,IAAIC,CAAAA,MAAQA,EAAKC,MAAMC,UAAU,CAAC,CAAC,EACnCC,MAAM,GAAGL,KAASD,EAAYO,MAAM,EACpCC,OAAOJ,CAAAA,MAASA,MAAU,EAAE,EAC5BK,KAAK,GAAG,CAAE;AACf;AAEA,SAASC,EACPC,GACAC,GACAC,GACA;AAEEF,SAAAA,EAAEC,WAAY,GAAEA,CAAO,MACvBD,EAAEC,WAAY,GAAEA,CAAO,SACvBD,EAAEC,WAAY,GAAEC,CAAM,IAAGD,CAAO,SAChCD,EAAEC,WAAY,GAAEC,CAAM,IAAGD,CAAO;AAEpC;AAEA,MAAME,IAAgBA,MAAM;;AAC1B,QAAMC,IAASC,KACTC,IAAeC,EAAQ,MAAM;;AACjC,UAAMC,IAAUA,CAACC,GAAgCC,IAAO,OAC/CD,EAAME,OAAgC,CAACC,GAAKpB,MAAS;AAE1D,YAAMC,IAAS,GAAEiB,CAAK,GAAElB,EAAKC,KAAM;AACnCmB,aAAAA,EAAIC,KAAK;AAAA,QAAE,GAAGrB;AAAAA,QAA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A,IAAAA,GACvB,OAAOG,EAAgBvB,MACnBwB,OAAOC,KAAKF,CAAe,EAAEvD,WAAW,MACxBV,IAAAA,WAKxBgC,EAAoByB,GAAMQ,CAAe;AAAA,EAAA,GAE3C,CAAC1B,GAAcP,CAAmB,CACpC;AAEO,SAAA;AAAA,IAAEO,cAAAA;AAAAA,IAAcsB,UAAAA;AAAAA,EAAAA;AACzB,GAEAO,IAAenD;"}
1
+ {"version":3,"file":"useNavigation.js","sources":["../../../../src/lib/hooks/useNavigation.tsx"],"sourcesContent":["import { useCallback, useContext, useMemo, useRef } from \"react\";\nimport { Path, useNavigate } from \"react-router-dom\";\n\nimport {\n HvAppShellViewContext,\n HvAppShellViewsConfig,\n useHvAppShellConfig\n} from \"@hitachivantara/app-shell-shared\";\n\nimport { NavigationOptions, To, ViewDestination } from \"../types\";\nimport compileHref from \"../utils/navigationUtil\";\nimport useHvLocation from \"./useLocation\";\n\nconst isViewDestination = (to: To): to is ViewDestination => {\n return (to as ViewDestination).viewBundle !== undefined;\n};\n\nconst isPathDestination = (to: To): to is Partial<Path> => {\n return typeof to !== \"string\" && !isViewDestination(to);\n};\n\ntype ViewSearchMode = \"auto\" | \"top\";\n\ninterface GetViewRouteOptions {\n mode?: ViewSearchMode;\n}\n\ntype NavigateOptions = GetViewRouteOptions & Partial<NavigationOptions>;\n\nfunction getActiveViewRoute(\n activeViews: HvAppShellViewsConfig[],\n depth?: number\n): string {\n return `/${activeViews\n .map(view => view.route.substring(1))\n .slice(0, depth ?? activeViews.length)\n .filter(route => route !== \"\") // remove index routes\n .join(\"/\")}`;\n}\n\nfunction isSameBundle(\n v: HvAppShellViewsConfig,\n bundle: string,\n appId: string | undefined\n) {\n return (\n v.bundle === `${bundle}` ||\n v.bundle === `${bundle}.js` ||\n v.bundle === `${appId}/${bundle}.js` ||\n v.bundle === `${appId}/${bundle}`\n );\n}\n\nconst useNavigation = () => {\n const config = useHvAppShellConfig();\n const flattenViews = useMemo(() => {\n const flatten = (views: HvAppShellViewsConfig[], base = \"\") => {\n return views.reduce<HvAppShellViewsConfig[]>((acc, view) => {\n // concatenate base with view route\n const route = `${base}${view.route}` as HvAppShellViewsConfig[\"route\"];\n acc.push({ ...view, route });\n if (view.views != null) {\n acc.push(...flatten(view.views, route));\n }\n return acc;\n }, []);\n };\n return flatten(config.mainPanel?.views ?? []);\n }, [config.mainPanel?.views]);\n\n const viewContext = useContext(HvAppShellViewContext);\n const navigateReactRouter = useNavigate();\n\n // the returned navigate and getViewRoute functions need to be stable\n // regardless of the location change, but we need to use the most recent location\n // in the getViewRoute algorithm, so we use a ref to store the location\n const location = useHvLocation();\n const locationRef = useRef(location);\n locationRef.current = location;\n\n /**\n * Utility to search for the route of a View on the App Shell configuration.\n *\n * The search can be performed in different modes:\n * - \"auto\": Searches within views whose route is a subpath of the current active view, progressively going up path segments until a match is found.\n * - \"top\": Finds the view closest to the root, i.e. with the least number of path segments.\n *\n * If multiple views match the search criteria, the function returns the one that appears first in the App Shell configuration.\n *\n * @param viewBundleDir The application view bundle directory name and optional route parameters.\n * @param mode The search mode to use. Defaults to \"auto\".\n *\n * @returns The compiled route or undefined if none was found.\n */\n const getViewRoute = useCallback(\n (\n viewBundleDir: string | ViewDestination,\n { mode = \"auto\" }: GetViewRouteOptions = {}\n ): string | undefined => {\n let viewBundle;\n let pathParams;\n let search;\n let hash;\n\n if (isViewDestination(viewBundleDir)) {\n ({ viewBundle, pathParams, search, hash } = viewBundleDir);\n } else {\n viewBundle = viewBundleDir;\n }\n const bundleWithReplacedPlaceholders = viewBundle.replace(/\\$/, \"_\");\n\n let appId: string | undefined;\n let bundle: string;\n\n // local navigation\n if (bundleWithReplacedPlaceholders.startsWith(\"/\")) {\n appId = viewContext?.id;\n bundle = bundleWithReplacedPlaceholders.substring(1);\n } else {\n bundle = bundleWithReplacedPlaceholders;\n }\n\n let activeViews: HvAppShellViewsConfig[] = [];\n if (mode !== \"top\") {\n activeViews = locationRef.current.views;\n }\n\n let route: string | undefined;\n\n const matchingViews = flattenViews\n .filter(v => isSameBundle(v, bundle, appId))\n .sort((a, b) => {\n const aSlashCount = (a.route.match(/\\//g) ?? []).length;\n const bSlashCount = (b.route.match(/\\//g) ?? []).length;\n return aSlashCount - bSlashCount;\n });\n\n if (matchingViews.length > 0) {\n if (mode === \"top\" || matchingViews.length === 1) {\n // no need for search algorithms if there is only one matching view\n route = matchingViews[0].route;\n } else if (mode === \"auto\") {\n const activeViewRoute = getActiveViewRoute(activeViews);\n\n let path = `${activeViewRoute}/`;\n while (route == null) {\n const innerPath = path;\n route = matchingViews.find(v =>\n v.route.startsWith(innerPath)\n )?.route;\n\n // remove last path segment, e.g. /path/segment/ -> /path/ -> /\n path = path.replace(/\\/[^/]*\\/?$/, \"/\");\n\n if (path === \"\") {\n break;\n }\n }\n }\n }\n\n return route\n ? `${compileHref(route, pathParams)}${search ?? \"\"}${hash ?? \"\"}`\n : undefined;\n },\n [flattenViews, viewContext?.id]\n );\n\n /**\n * Performs navigation, through 'history.push' or 'history.replace', for the given destination with the passed navigation options.\n * @see https://reactrouter.com/hooks/use-navigate\n *\n * @param to The destination of the navigation. For ViewDestination type see {@link ViewDestination}.\n * @param options The navigation options:\n * - mode: The search mode to use when searching for the route of a View on the App Shell configuration. Defaults to \"auto\".\n * - replace: If true, the navigation will replace the current entry in the history stack instead of adding a new one.\n * - state: State to associate to the location.\n */\n const navigate = useCallback(\n (to: To, options?: NavigateOptions) => {\n let path;\n if (isPathDestination(to)) {\n path = to;\n } else {\n const route = getViewRoute(to, { mode: options?.mode });\n\n if (route == null) {\n if (typeof to === \"string\") {\n path = to;\n } else {\n // If route for given module is not found on the App Shell configuration file, do nothing.\n console.warn(\n `Navigate request to a non existing path [${to.viewBundle}]. Skipping`\n );\n return;\n }\n } else {\n path = route;\n }\n }\n\n let navigateOptions: NavigateOptions | undefined;\n if (options != null) {\n if (options.mode == null) {\n navigateOptions = options;\n } else {\n navigateOptions = { ...options };\n delete navigateOptions.mode;\n if (Object.keys(navigateOptions).length === 0) {\n navigateOptions = undefined;\n }\n }\n }\n\n navigateReactRouter(path, navigateOptions);\n },\n [getViewRoute, navigateReactRouter]\n );\n\n return { getViewRoute, navigate };\n};\n\nexport default useNavigation;\n"],"names":["isViewDestination","to","viewBundle","undefined","isPathDestination","getActiveViewRoute","activeViews","depth","map","view","route","substring","slice","length","filter","join","isSameBundle","v","bundle","appId","useNavigation","config","useHvAppShellConfig","flattenViews","useMemo","flatten","views","base","reduce","acc","push","mainPanel","viewContext","useContext","HvAppShellViewContext","navigateReactRouter","useNavigate","location","useHvLocation","locationRef","useRef","current","getViewRoute","useCallback","viewBundleDir","mode","pathParams","search","hash","bundleWithReplacedPlaceholders","replace","startsWith","id","matchingViews","sort","a","b","aSlashCount","match","bSlashCount","path","innerPath","find","compileHref","navigate","options","console","warn","navigateOptions","Object","keys","useNavigation$1"],"mappings":";;;;;AAaA,MAAMA,IAAoBA,CAACC,MACjBA,EAAuBC,eAAeC,QAG1CC,IAAoBA,CAACH,MAClB,OAAOA,KAAO,YAAY,CAACD,EAAkBC,CAAE;AAWxD,SAASI,EACPC,GACAC,GACQ;AACA,SAAA,IAAGD,EACRE,IAAIC,CAAAA,MAAQA,EAAKC,MAAMC,UAAU,CAAC,CAAC,EACnCC,MAAM,GAAGL,KAASD,EAAYO,MAAM,EACpCC,OAAOJ,CAAAA,MAASA,MAAU,EAAE,EAC5BK,KAAK,GAAG,CAAE;AACf;AAEA,SAASC,EACPC,GACAC,GACAC,GACA;AAEEF,SAAAA,EAAEC,WAAY,GAAEA,CAAO,MACvBD,EAAEC,WAAY,GAAEA,CAAO,SACvBD,EAAEC,WAAY,GAAEC,CAAM,IAAGD,CAAO,SAChCD,EAAEC,WAAY,GAAEC,CAAM,IAAGD,CAAO;AAEpC;AAEA,MAAME,IAAgBA,MAAM;;AAC1B,QAAMC,IAASC,KACTC,IAAeC,EAAQ,MAAM;;AACjC,UAAMC,IAAUA,CAACC,GAAgCC,IAAO,OAC/CD,EAAME,OAAgC,C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,QAAAA,IAAAA;AAAAA,IAEX;AAEI0D,QAAAA;AACJ,IAAIH,KAAW,SACTA,EAAQpB,QAAQ,OACAoB,IAAAA,KAEAG,IAAA;AAAA,MAAE,GAAGH;AAAAA,IAAAA,GACvB,OAAOG,EAAgBvB,MACnBwB,OAAOC,KAAKF,CAAe,EAAEvD,WAAW,MACxBV,IAAAA,WAKxBgC,EAAoByB,GAAMQ,CAAe;AAAA,EAAA,GAE3C,CAAC1B,GAAcP,CAAmB,CACpC;AAEO,SAAA;AAAA,IAAEO,cAAAA;AAAAA,IAAcsB,UAAAA;AAAAA,EAAAA;AACzB,GAEAO,IAAenD;"}
@@ -1,9 +1,9 @@
1
1
  import { compile as c } from "path-to-regexp";
2
- const r = (e, o) => o ? c(e, {
2
+ const l = (e, o) => o ? c(e, {
3
3
  encode: encodeURIComponent,
4
4
  validate: !1
5
- })(o) : e, m = r;
5
+ })(o) : e;
6
6
  export {
7
- m as default
7
+ l as default
8
8
  };
9
9
  //# sourceMappingURL=navigationUtil.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigationUtil.js","sources":["../../../../src/lib/utils/navigationUtil.tsx"],"sourcesContent":["import { compile } from \"path-to-regexp\";\n\n/**\n * Utility that replaces the href placeholders with the href options provided.\n * The href parameter must not contain 'search' nor 'hash' parts.\n * @example\n * // returns '/home/2'\n * // href: '/home/:id', hrefOptions: '{id: 2}'\n *\n * @param href The string to be compiled.\n * @param hrefOptions The options to replace the placeholders on the href.\n *\n * @returns The compiled href\n */\nconst compileHref = (\n href: string,\n hrefOptions?: Record<string, string>\n): string => {\n if (!hrefOptions) {\n return href;\n }\n\n const compiler = compile(href, {\n encode: encodeURIComponent,\n validate: false\n });\n\n return compiler(hrefOptions);\n};\n\nexport default compileHref;\n"],"names":["compileHref","href","hrefOptions","compile","encode","encodeURIComponent","validate","compileHref$1"],"mappings":";AAcA,MAAMA,IAAcA,CAClBC,GACAC,MAEKA,IAIYC,EAAQF,GAAM;AAAA,EAC7BG,QAAQC;AAAAA,EACRC,UAAU;AAAA,CACX,EAEeJ,CAAW,IARlBD,GAWXM,IAAeP;"}
1
+ {"version":3,"file":"navigationUtil.js","sources":["../../../../src/lib/utils/navigationUtil.tsx"],"sourcesContent":["import { compile } from \"path-to-regexp\";\n\n/**\n * Utility that replaces the href placeholders with the href options provided.\n * The href parameter must not contain 'search' nor 'hash' parts.\n * @example\n * // returns '/home/2'\n * // href: '/home/:id', hrefOptions: '{id: 2}'\n *\n * @param href The string to be compiled.\n * @param hrefOptions The options to replace the placeholders on the href.\n *\n * @returns The compiled href\n */\nconst compileHref = (\n href: string,\n hrefOptions?: Record<string, string>\n): string => {\n if (!hrefOptions) {\n return href;\n }\n\n const compiler = compile(href, {\n encode: encodeURIComponent,\n validate: false\n });\n\n return compiler(hrefOptions);\n};\n\nexport default compileHref;\n"],"names":["compileHref","href","hrefOptions","compile","encode","encodeURIComponent","validate"],"mappings":";AAcMA,MAAAA,IAAcA,CAClBC,GACAC,MAEKA,IAIYC,EAAQF,GAAM;AAAA,EAC7BG,QAAQC;AAAAA,EACRC,UAAU;AAAA,CACX,EAEeJ,CAAW,IARlBD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/app-shell-navigation",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "AppShell Navigation",
5
5
  "author": "Hitachi Vantara - Boba Fett Team",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "coverage": "vitest run --coverage"
36
36
  },
37
37
  "dependencies": {
38
- "@hitachivantara/app-shell-shared": "1.2.0",
38
+ "@hitachivantara/app-shell-shared": "1.2.1",
39
39
  "path-to-regexp": "^6.2.1"
40
40
  },
41
41
  "peerDependencies": {
@@ -56,5 +56,5 @@
56
56
  "vite-plugin-dts": "^3.6.4",
57
57
  "vite-tsconfig-paths": "^4.0.5"
58
58
  },
59
- "gitHead": "f32c45a8012716dd25df32f98efe5bb2c4457209"
59
+ "gitHead": "14eb397d067e6018dc043762d5fb40e631b89942"
60
60
  }