@common-stack/client-react 3.0.3-alpha.8 → 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,8 +1,17 @@
1
1
  import { IReactFeature } from '../interfaces';
2
2
  import { BaseFeature } from './base-connector';
3
3
  export declare class Feature extends BaseFeature implements IReactFeature {
4
- protected renderRoutes: (args: any) => import("react").JSX.Element;
4
+ protected renderRoutes: (arg1: any, arg2: any) => import("react").JSX.Element;
5
+ /**
6
+ * @deprecated: use `renderRoutes`
7
+ * @param arg1
8
+ * @param arg2
9
+ * @returns
10
+ */
5
11
  protected renderRoutes2: (arg1: any, arg2: any) => import("react").JSX.Element;
6
- protected getSortedRoutes: (path: string, routeData: import("../interfaces").IRouteData, authWrapper?: (ele: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, props: Record<string, any>) => void) => any;
12
+ protected getSortedRoutes: (path: string, routeData: import("../interfaces").IRouteData, authWrapper?: (component: import("react").FC<{}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => any;
13
+ /**
14
+ * @deprecated use getSortedRoutes
15
+ */
7
16
  protected getSortedRoutes2: (path: string, routeData: import("../interfaces").IRouteData, authWrapper?: (component: import("react").FC<{}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => any;
8
17
  }
@@ -1,9 +1,18 @@
1
- import {BaseFeature}from'./base-connector.js';import {renderRoutes}from'../route/render-routes-native.js';import resolveRootRoute from'../route/react-navigation/react-navigation-render.js';import {getSortedRoutes}from'../route/get-routes.js';import {getSortedNavigations}from'../route/react-navigation/get-navigation-utils.js';class Feature extends BaseFeature {
1
+ import {BaseFeature}from'./base-connector.js';import resolveRootRoute from'../route/react-navigation/react-navigation-render.js';import {getSortedNavigations}from'../route/react-navigation/get-navigation-utils.js';class Feature extends BaseFeature {
2
2
  constructor() {
3
3
  super(...arguments);
4
- this.renderRoutes = (args) => renderRoutes({ routes: args });
4
+ this.renderRoutes = (arg1, arg2) => resolveRootRoute(arg1[0], arg2);
5
+ /**
6
+ * @deprecated: use `renderRoutes`
7
+ * @param arg1
8
+ * @param arg2
9
+ * @returns
10
+ */
5
11
  this.renderRoutes2 = (arg1, arg2) => resolveRootRoute(arg1[0], arg2);
6
- this.getSortedRoutes = getSortedRoutes;
12
+ this.getSortedRoutes = getSortedNavigations;
13
+ /**
14
+ * @deprecated use getSortedRoutes
15
+ */
7
16
  this.getSortedRoutes2 = getSortedNavigations;
8
17
  }
9
18
  }export{Feature};//# sourceMappingURL=connector.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connector.native.js","sources":["../../src/connector/connector.native.tsx"],"sourcesContent":[null],"names":["renderNavigation"],"mappings":"uUAOM,MAAO,OAAQ,SAAQ,WAAW,CAAA;AAAxC,IAAA,WAAA,GAAA;;AACc,QAAA,IAAA,CAAA,YAAY,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AACxD,QAAA,IAAA,CAAA,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,KAAKA,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChE,IAAe,CAAA,eAAA,GAAG,eAAe,CAAC;QAClC,IAAgB,CAAA,gBAAA,GAAG,oBAAoB,CAAC;KACrD;AAAA"}
1
+ {"version":3,"file":"connector.native.js","sources":["../../src/connector/connector.native.tsx"],"sourcesContent":[null],"names":["renderNavigation"],"mappings":"sNAKM,MAAO,OAAQ,SAAQ,WAAW,CAAA;AAAxC,IAAA,WAAA,GAAA;;AACc,QAAA,IAAA,CAAA,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,KAAKA,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACzE;;;;;AAKG;AACO,QAAA,IAAA,CAAA,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,KAAKA,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChE,IAAe,CAAA,eAAA,GAAG,oBAAoB,CAAC;AACjD;;AAEG;QACO,IAAgB,CAAA,gBAAA,GAAG,oBAAoB,CAAC;KACrD;AAAA"}
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.js';export{FeatureWithRouterFactory}from'./router-factory/index.js';export{renderRoutes2}from'./route/render-routes.js';import'react';export{getNavigation,getSortedNavigations}from'./route/react-navigation/get-navigation-utils.js';export{navigate,navigationRef}from'./route/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{IMenuPosition}from'./interfaces/menu.js';export{PluginArea}from'./plugin-area/index.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.js.map
1
+ export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.js';export{FeatureWithRouterFactory}from'./router-factory/index.js';export{renderRoutes2}from'./route/render-routes.js';import'react';export{getNavigation,getSortedNavigations}from'./route/react-navigation/get-navigation-utils.js';export{navigate,navigationRef}from'./route/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{getFilteredMenus,getFilteredRoutes,getFilteredTabs}from'./utils/filteredRoutes.js';export{IMenuPosition}from'./interfaces/menu.js';export{PluginArea}from'./plugin-area/index.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  export { ClientTypes } from '@common-stack/client-core';
2
2
  export * from './connector/connector.native';
3
3
  export * from './router-factory/index.native';
4
- export * from './route/index.native';
5
4
  export * from './route/react-navigation/root-navigation';
6
5
  export * from './utils';
7
6
  export * from './interfaces';
@@ -1 +1 @@
1
- export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.native.js';export{FeatureWithRouterFactory}from'./router-factory/index.native.js';export{renderRoutes}from'./route/render-routes-native.js';export{navigate,navigationRef}from'./route/react-navigation/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{IMenuPosition}from'./interfaces/menu.js';export{PluginArea}from'./plugin-area/index.native.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.native.js.map
1
+ export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.native.js';export{FeatureWithRouterFactory}from'./router-factory/index.native.js';export{navigate,navigationRef}from'./route/react-navigation/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{getFilteredMenus,getFilteredRoutes,getFilteredTabs}from'./utils/filteredRoutes.js';export{IMenuPosition}from'./interfaces/menu.js';export{PluginArea}from'./plugin-area/index.native.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.native.js.map
@@ -1,67 +1,102 @@
1
- import {IMenuPosition}from'../interfaces/menu.js';import {sortKeys}from'../utils/sort-keys.js';import {formatSlash}from'../utils/utils.js';import'lodash-es';import'@common-stack/client-core';const getSortedRoutes = (path, routeData, authWrapper = null) => {
1
+ import {IMenuPosition}from'../interfaces/menu.js';import {sortKeys}from'../utils/sort-keys.js';import {formatSlash}from'../utils/utils.js';// Function to get sorted routes based on a given path, route data, and an optional authentication wrapper.
2
+ const getSortedRoutes = (path, routeData, authWrapper = null) => {
3
+ // Sort the keys of the route data for consistency.
2
4
  const sortedRoutes = sortKeys(routeData);
5
+ // Pass the sorted route data to getRoutes function.
3
6
  return getRoutes(path, sortedRoutes, authWrapper);
4
7
  };
8
+ // Function to process and return routes based on the given path, route data, and auth wrapper.
5
9
  function getRoutes(path, routeData, authWrapper = null) {
10
+ // Ensure the provided path starts with a '/'.
6
11
  if (!path.startsWith('/')) {
7
12
  throw new Error('Invalid path!');
8
13
  }
14
+ // Normalize the path to ensure it ends with '/' for consistent matching.
9
15
  let searchPath = path;
10
16
  if (path[path.length - 1] !== '/') {
11
17
  searchPath = path + '/';
12
18
  }
13
- const routes = Object.keys(routeData).filter(menuPath => {
19
+ // Filter the routes from the routeData based on the search path or exact path match.
20
+ const routes = Object.keys(routeData).filter((menuPath) => {
14
21
  return menuPath.indexOf(searchPath) === 0 || menuPath === path;
15
22
  });
16
- const mappedMenuPaths = routes.map(mPath => {
23
+ // Map the filtered routes to include additional properties and merge with routeData.
24
+ const mappedMenuPaths = routes.map((mPath) => {
17
25
  return {
18
26
  route: mPath,
19
27
  position: IMenuPosition.Middle,
20
28
  ...routeData[mPath],
21
29
  };
22
30
  });
31
+ // Initialize the root route object with a placeholder name and position.
23
32
  const root = {
24
33
  // just to satisfy types added following
25
34
  // TOOD need to correct types so we don't have to enter them.
26
35
  name: 'root',
27
36
  position: IMenuPosition.Logo,
28
37
  };
29
- mappedMenuPaths.forEach(routeItem => {
38
+ // Iterate over the mapped routes to build the nested route structure.
39
+ mappedMenuPaths.forEach((routeItem) => {
40
+ // Split the route path to process each segment.
30
41
  const children = routeItem.route.split('/');
31
- children.shift();
32
- // if the route is `/` then add this correction.
42
+ children.shift(); // Remove the first empty element from splitting.
43
+ // Special case handling for the root ('/') route.
33
44
  if (routeItem.path === '/') {
34
- children.shift();
35
- children.push('/');
45
+ children.shift(); // Adjust for root path.
46
+ children.push('/'); // Ensure the array reflects the root path.
36
47
  }
48
+ // Determine the depth of the current route for nested routing.
37
49
  const depth = children.length;
38
- let lastNode = root;
50
+ let lastNode = root; // Start building from the root.
51
+ // Iterate through each segment to find or create nested route nodes.
39
52
  for (let i = 0; i < depth; i++) {
40
- const lastIndex = (lastNode.routes || []).findIndex(item => {
53
+ const lastIndex = (lastNode.routes || []).findIndex((item) => {
41
54
  const routePath = `${item._pathPrefix}${item.path}`;
42
55
  if (routeItem.route.startsWith(routePath)) {
43
- // only if the parent path has `exact: false` allows to nested
56
+ // Check if the route starts with the path prefix and if nested routing is allowed.
44
57
  return routeItem.route[routePath.length] === '/' && routeData[routePath]?.exact === false;
45
58
  }
46
59
  });
60
+ // Break the loop if no further nested route is found.
47
61
  if (lastIndex === -1) {
48
62
  break;
49
63
  }
64
+ // Navigate to the last found nested route.
50
65
  lastNode = lastNode.routes[lastIndex];
51
66
  // const lastNodePath = `${(lastNode as any)._pathPrefix}${lastNode.path}`;
52
67
  // lastNode.exact = routeData[lastNodePath].hasOwnProperty('exact') ? routeData[lastNodePath].exact : false;
53
68
  }
69
+ // Ensure the last node has a routes array to push into.
54
70
  if (!lastNode.routes) {
55
71
  lastNode.routes = [];
56
72
  }
73
+ // Extract relevant properties to construct the final route object.
57
74
  const { route: ignore, auth, ...rest } = routeItem;
58
75
  const pathParams = formatSlash(routeItem.route);
76
+ // Determine the parent path for the current route
77
+ // Attempt to construct parentPath more defensively
78
+ let parentPath;
79
+ if (lastNode && lastNode !== root) {
80
+ // Ensure lastNode is not the root and is defined
81
+ parentPath = '';
82
+ if (lastNode._pathPrefix) {
83
+ parentPath += lastNode._pathPrefix;
84
+ }
85
+ if (lastNode.path) {
86
+ parentPath += lastNode.path;
87
+ }
88
+ }
89
+ const relativePath = routeItem.route.replace(new RegExp(`^${parentPath}/?`), '');
59
90
  lastNode.routes.push({
60
91
  ...rest,
61
92
  // path: formatSlash(routeItem.route),
62
93
  // path: routeItem.route,
63
94
  ...pathParams,
95
+ relativePath,
96
+ auth: auth,
64
97
  exact: routeData[routeItem.route].hasOwnProperty('exact') ? routeData[routeItem.route].exact : true,
98
+ // ...(parentPath !== '/' && { parentPath }),
99
+ parentPath,
65
100
  /**
66
101
  * Here we are checking whether auth property is being
67
102
  * set by this route and if authWrapper is declared
@@ -69,9 +104,7 @@ function getRoutes(path, routeData, authWrapper = null) {
69
104
  * and its props as argument then perform some
70
105
  * computation and return a component
71
106
  */
72
- component: auth && authWrapper
73
- ? (props) => authWrapper(routeItem.component, props)
74
- : routeItem.component
107
+ component: auth && authWrapper ? (props) => authWrapper(routeItem.component, props) : routeItem.component,
75
108
  });
76
109
  });
77
110
  return root.routes;
@@ -1 +1 @@
1
- {"version":3,"file":"get-routes.js","sources":["../../src/route/get-routes.tsx"],"sourcesContent":[null],"names":[],"mappings":"+LAIO,MAAM,eAAe,GAAG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QAAA,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;AACjB,YAAA,GAAG,IAAI;;;AAGP,YAAA,GAAG,UAAU;YACb,YAAY;AACZ,YAAA,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI;;YAEnG,UAAU;AACV;;;;;;AAMG;YACH,SAAS,EAAE,IAAI,IAAI,WAAW,GAAG,CAAC,KAAK,KAAK,WAAW,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,SAAS;AAC5G,SAAA,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB"}
@@ -0,0 +1,3 @@
1
+ export declare const getFilteredMenus: (accountPageStore: any, selectedMenu?: string) => any;
2
+ export declare const getFilteredRoutes: (accountPageStore: any, selectedRoutes?: string) => any;
3
+ export declare const getFilteredTabs: (accountPageStore: any, selectedTabs?: string) => any;
@@ -0,0 +1,31 @@
1
+ const getFilteredMenus = (accountPageStore, selectedMenu = '*') => accountPageStore
2
+ .map((item) => {
3
+ if (selectedMenu === '*' || selectedMenu.includes(item.key)) {
4
+ const { path, component, ...rest } = item;
5
+ return {
6
+ [path]: { name: rest.tab, ...rest },
7
+ };
8
+ }
9
+ return null;
10
+ })
11
+ .filter((valid) => valid);
12
+ const getFilteredRoutes = (accountPageStore, selectedRoutes = '*') => accountPageStore
13
+ .map((item) => {
14
+ if (selectedRoutes === '*' || selectedRoutes.includes(item.key)) {
15
+ const { path } = item;
16
+ return {
17
+ [path]: item,
18
+ };
19
+ }
20
+ return null;
21
+ })
22
+ .filter((valid) => valid);
23
+ const getFilteredTabs = (accountPageStore, selectedTabs = '*') => accountPageStore
24
+ .map((item) => {
25
+ if (selectedTabs === '*' || selectedTabs.includes(item.key)) {
26
+ const { component, ...rest } = item;
27
+ return rest;
28
+ }
29
+ return null;
30
+ })
31
+ .filter((valid) => valid);export{getFilteredMenus,getFilteredRoutes,getFilteredTabs};//# sourceMappingURL=filteredRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filteredRoutes.js","sources":["../../src/utils/filteredRoutes.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,gBAAgB,GAAG,CAAC,gBAAgB,EAAE,YAAY,GAAG,GAAG,KACnE,gBAAgB;AACb,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACZ,IAAA,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC3D,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC1C,OAAO;AACL,YAAA,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE;SACpC,CAAC;AACH,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE;AAEvB,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,cAAc,GAAG,GAAG,KACtE,gBAAgB;AACb,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACZ,IAAA,IAAI,cAAc,KAAK,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAC/D,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,OAAO;YACL,CAAC,IAAI,GAAG,IAAI;SACb,CAAC;AACH,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE;AAEvB,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,YAAY,GAAG,GAAG,KAClE,gBAAgB;AACb,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACZ,IAAA,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AACpC,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK"}
@@ -3,3 +3,4 @@ export * from './utils';
3
3
  export * from './combine';
4
4
  export * from './hydrate';
5
5
  export * from './before-ssr';
6
+ export * from './filteredRoutes';
@@ -5,14 +5,14 @@ function sortByPaths(routes) {
5
5
  const routeData = {};
6
6
  routes.forEach((route) => {
7
7
  if (typeof route.path === 'undefined') {
8
- route.path = "*";
8
+ route.path = '*';
9
9
  }
10
10
  routeData[route.path] = route;
11
11
  });
12
12
  const sortedRoutes = defaultSortKeys(routeData, { compare });
13
- return Object.keys(sortedRoutes).map(key => sortedRoutes[key]);
13
+ return Object.keys(sortedRoutes).map((key) => sortedRoutes[key]);
14
14
  }
15
- const compare = ((a, b) => {
15
+ const compare = (a, b) => {
16
16
  const aStr = String(a).toLowerCase();
17
17
  const bStr = String(b).toLowerCase();
18
18
  // Alphanumeric elements always come before non-alphanumeric elements
@@ -28,7 +28,7 @@ const compare = ((a, b) => {
28
28
  if (aIsAlphanumeric > 0) {
29
29
  return -1;
30
30
  }
31
- else if (bIsAlphanumeric > 0) {
31
+ if (bIsAlphanumeric > 0) {
32
32
  return 1;
33
33
  }
34
34
  }
@@ -40,38 +40,39 @@ const compare = ((a, b) => {
40
40
  return aNum - bNum;
41
41
  // If a is numerical but b isn't, put a first.
42
42
  }
43
- else if (aNum) {
43
+ if (aNum) {
44
44
  return -1;
45
45
  // If b is numerical but a isn't, put b first.
46
46
  }
47
- else if (bNum) {
47
+ if (bNum) {
48
48
  return 1;
49
49
  }
50
50
  // In all other cases, default to usual sort order.
51
51
  return aStr.localeCompare(bStr);
52
- });
52
+ };
53
53
  function notStartWithColon(str) {
54
54
  const match = (str.match(/^[\/, *, :]{1,}/) || [-1])[0];
55
55
  if (match === -1) {
56
56
  return -1;
57
57
  }
58
- var i = match.length;
58
+ let i = match.length;
59
59
  let count = 0;
60
60
  while (i--) {
61
61
  const char = match[i];
62
62
  if (char === '/') {
63
- if (str === '/') { // if it is root only we put at the last
64
- count = count + 6;
63
+ if (str === '/') {
64
+ // if it is root only we put at the last
65
+ count += 6;
65
66
  }
66
67
  else {
67
- count = count + 3;
68
+ count += 3;
68
69
  }
69
70
  }
70
71
  else if (char === ':') {
71
- count = count + 1;
72
+ count += 1;
72
73
  }
73
74
  else if (char === '*') {
74
- count = count + 2;
75
+ count += 2;
75
76
  }
76
77
  }
77
78
  return count;
@@ -1 +1 @@
1
- {"version":3,"file":"sort-keys.js","sources":["../../src/utils/sort-keys.ts"],"sourcesContent":[null],"names":[],"mappings":"uCAEM,SAAU,QAAQ,CAAC,SAAS,EAAA;IAChC,OAAO,eAAe,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;AAChD,CAAC;AAEK,SAAU,WAAW,CAAC,MAAM,EAAA;IAChC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,IAAA,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;AACvB,QAAA,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;AACrC,YAAA,KAAK,CAAC,IAAI,GAAG,GAAG,CAAA;AACjB,SAAA;AACD,QAAA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;AAC/B,KAAC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7D,IAAA,OAAO,MAAM,CAAC,IAAI,CAA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AK,CAAC;AACjB"}
@@ -1,8 +1,7 @@
1
1
  const startWithMoreThanOneSlash = /^(\/)\1+/; // for exame `//abc, ///abc, ...`
2
- const formatSlash = (route) => {
3
- // replaced `//` with `/` in the routes.
4
- return {
5
- path: route.replace(startWithMoreThanOneSlash, '/'),
6
- _pathPrefix: (route.match(/^\/(\/{1,})/) || ['', ''])[1],
7
- };
8
- };export{formatSlash};//# sourceMappingURL=utils.js.map
2
+ const formatSlash = (route) =>
3
+ // replaced `//` with `/` in the routes.
4
+ ({
5
+ path: route.replace(startWithMoreThanOneSlash, '/'),
6
+ _pathPrefix: (route.match(/^\/(\/{1,})/) || ['', ''])[1],
7
+ });export{formatSlash};//# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../src/utils/utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAChC,MAAA,WAAW,GAAG,CAAC,KAAK,KAAI;;IAEnC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC;AACnD,QAAA,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;KACzD,CAAA;AACH"}
1
+ {"version":3,"file":"utils.js","sources":["../../src/utils/utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAChC,MAAA,WAAW,GAAG,CAAC,KAAK;AAC7B;AACA,CAAC;IACG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC;AACnD,IAAA,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/client-react",
3
- "version": "3.0.3-alpha.8",
3
+ "version": "4.0.1-alpha.1",
4
4
  "description": "Client Module for react app",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -30,8 +30,8 @@
30
30
  "watch": "npm run build:lib:watch"
31
31
  },
32
32
  "dependencies": {
33
- "@common-stack/client-core": "3.0.3-alpha.8",
34
- "@common-stack/core": "3.0.3-alpha.8",
33
+ "@common-stack/client-core": "4.0.1-alpha.0",
34
+ "@common-stack/core": "4.0.1-alpha.0",
35
35
  "@wordpress/hooks": "^3.53.0",
36
36
  "browser-bunyan": "^1.6.3",
37
37
  "history-with-query": "^4.10.4",
@@ -51,7 +51,7 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "af6a81b8b3a0142729d11fdbd7f3c790e117a8ee",
54
+ "gitHead": "964e8026cdb5b321f60c38bddb3e979b3affc44e",
55
55
  "typescript": {
56
56
  "definition": "lib/index.d.ts"
57
57
  }
@@ -1 +0,0 @@
1
- export * from './render-routes-native';
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare function renderRoutes(opts: any): React.JSX.Element;
3
- export { renderRoutes };
@@ -1,68 +0,0 @@
1
- import*as React from'react';import {Routes,Route,Navigate}from'react-router-native';function render({ route, opts, props }) {
2
- const routes = renderRoutes({
3
- ...opts,
4
- routes: route.routes || [],
5
- rootRoutes: opts.rootRoutes,
6
- });
7
- const { component: Component, wrappers } = route;
8
- if (Component) {
9
- const defaultPageInitialProps = opts.isServer ? {} : window.g_initialProps;
10
- const newProps = {
11
- ...props,
12
- ...opts.extraProps,
13
- ...(opts.pageInitialProps || defaultPageInitialProps),
14
- route,
15
- routes: opts.rootRoutes,
16
- };
17
- let element = React.createElement(Component, { ...newProps }, routes);
18
- if (wrappers) {
19
- element = wrappers.reduceRight((acc, Wrapper) => {
20
- return React.createElement(Wrapper, { ...newProps }, acc);
21
- }, element);
22
- }
23
- return element;
24
- }
25
- return routes;
26
- }
27
- function getRouteElement({ route, index, opts }) {
28
- ({
29
- key: route.key || index,
30
- exact: route.exact,
31
- strict: route.strict,
32
- sensitive: route.sensitive,
33
- path: route.path,
34
- });
35
- if (route.redirect) {
36
- return React.createElement(Route, { key: route.key || index, path: route.path, element: React.createElement(Navigate, { to: route.redirect, replace: true }) });
37
- }
38
- // avoid mount and unmount with url hash change
39
- // @sri not supproted yet
40
- // if (
41
- // // only when SSR config enable
42
- // opts.ssrProps &&
43
- // !opts.isServer &&
44
- // // make sure loaded once
45
- // !(route.component as any)?.wrapInitialPropsLoaded &&
46
- // (route.component?.getInitialProps || route.component?.preload)
47
- // ) {
48
- // // client Render for enable ssr, but not sure SSR success
49
- // route.component = wrapInitialPropsFetch(route, opts);
50
- // }
51
- return (React.createElement(Route, { key: route.key || index, path: route.path, element: React.createElement(RouteElementWrapper, { route: route, render: render, opts: opts }) }));
52
- }
53
- function RouteElementWrapper({ route, render, opts }) {
54
- const element = render({ route, opts, props: {} });
55
- return React.createElement(React.Fragment, null, element);
56
- }
57
- function renderRoutes(opts) {
58
- return opts.routes ? (React.createElement(Routes, null, opts.routes.map((route, index) => {
59
- return getRouteElement({
60
- route,
61
- index,
62
- opts: {
63
- ...opts,
64
- rootRoutes: opts.rootRoutes || opts.routes,
65
- },
66
- });
67
- }))) : null;
68
- }export{renderRoutes};//# sourceMappingURL=render-routes-native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-routes-native.js","sources":["../../src/route/render-routes-native.tsx"],"sourcesContent":[null],"names":[],"mappings":"oFA+DA,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAA+D,EAAA;IACjG,MAAM,MAAM,GAAG,YAAY,CAAC;AAC1B,QAAA,GAAG,IAAI;AACP,QAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,KAAA,CAAC,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