@umijs/renderer-react 3.5.19 → 4.0.0-beta.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.
package/dist/routes.js ADDED
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ export function createClientRoutes(opts) {
3
+ const { routesById, parentId, Component } = opts;
4
+ return Object.keys(routesById)
5
+ .filter((id) => routesById[id].parentId === parentId)
6
+ .map((id) => {
7
+ const route = createClientRoute({
8
+ route: routesById[id],
9
+ Component,
10
+ });
11
+ const children = createClientRoutes({
12
+ routesById,
13
+ parentId: route.id,
14
+ Component,
15
+ });
16
+ if (children.length > 0) {
17
+ // @ts-ignore
18
+ route.children = children;
19
+ }
20
+ return route;
21
+ });
22
+ }
23
+ export function createClientRoute(opts) {
24
+ const { route, Component } = opts;
25
+ return {
26
+ id: route.id,
27
+ path: route.path,
28
+ index: route.index,
29
+ element: React.createElement(Component, { id: route.id }),
30
+ };
31
+ }
@@ -0,0 +1,9 @@
1
+ export interface IRoute {
2
+ id: string;
3
+ path?: string;
4
+ index?: boolean;
5
+ parentId?: string;
6
+ }
7
+ export interface IRoutesById {
8
+ [id: string]: IRoute;
9
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/package.json CHANGED
@@ -1,39 +1,41 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "3.5.19",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "@umijs/renderer-react",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
+ "scripts": {
11
+ "build": "pnpm tsc",
12
+ "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
13
+ "dev": "pnpm build -- --watch"
14
+ },
10
15
  "repository": {
11
16
  "type": "git",
12
- "url": "https://github.com/umijs/umi"
17
+ "url": "https://github.com/umijs/umi-next"
13
18
  },
14
- "keywords": [
15
- "umi"
16
- ],
17
- "sideEffects": false,
18
19
  "authors": [
19
20
  "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
20
21
  ],
21
22
  "license": "MIT",
22
- "bugs": "http://github.com/umijs/umi/issues",
23
- "homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
23
+ "bugs": "https://github.com/umijs/umi-next/issues",
24
+ "homepage": "https://github.com/umijs/umi-next/tree/master/packages/renderer-react#readme",
24
25
  "publishConfig": {
25
26
  "access": "public"
26
27
  },
27
28
  "dependencies": {
28
- "@types/react": "^16.9.43",
29
- "@types/react-dom": "^16.9.8",
30
- "@types/react-router-config": "^5.0.2",
31
- "@umijs/runtime": "3.5.19",
32
- "react-router-config": "5.1.1"
29
+ "history": "5.0.1",
30
+ "react-router-dom": "6.0.0-beta.8"
31
+ },
32
+ "devDependencies": {
33
+ "react": "18.0.0-alpha-f2c381131-20211004",
34
+ "react-dom": "18.0.0-alpha-f2c381131-20211004"
33
35
  },
34
36
  "peerDependencies": {
35
- "react": "16.x || 17.x",
36
- "react-dom": "16.x || 17.x"
37
+ "react": ">=16.8",
38
+ "react-dom": ">=16.8"
37
39
  },
38
- "module": "dist/index.esm.js"
40
+ "sideEffects": false
39
41
  }