agent-hel-react-comps 2.4.0
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/README.md +68 -0
- package/hel_dist/asset-manifest.json +19 -0
- package/hel_dist/favicon.ico +0 -0
- package/hel_dist/hel-meta.json +64 -0
- package/hel_dist/index.html +1 -0
- package/hel_dist/manifest.json +10 -0
- package/hel_dist/robots.txt +3 -0
- package/hel_dist/static/css/291.0bcd258f.chunk.css +2 -0
- package/hel_dist/static/css/291.0bcd258f.chunk.css.map +1 -0
- package/hel_dist/static/css/622.0bcd258f.chunk.css +2 -0
- package/hel_dist/static/css/622.0bcd258f.chunk.css.map +1 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js +3 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js.LICENSE.txt +9 -0
- package/hel_dist/static/js/291.8f4b8910.chunk.js.map +1 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js +3 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js.LICENSE.txt +9 -0
- package/hel_dist/static/js/622.15f5dd58.chunk.js.map +1 -0
- package/hel_dist/static/js/main.e596336d.js +3 -0
- package/hel_dist/static/js/main.e596336d.js.LICENSE.txt +16 -0
- package/hel_dist/static/js/main.e596336d.js.map +1 -0
- package/hel_dist/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg +1 -0
- package/hel_proxy/entry.js +23 -0
- package/hel_proxy_es/entry.js +14 -0
- package/lib/components/HelloRemoteReactComp/App.css +50 -0
- package/lib/components/HelloRemoteReactComp/App.test.tsx +10 -0
- package/lib/components/HelloRemoteReactComp/App.tsx +37 -0
- package/lib/components/HelloRemoteReactComp/index.css +13 -0
- package/lib/components/HelloRemoteReactComp/index.tsx +4 -0
- package/lib/components/HelloRemoteReactComp/logo.svg +1 -0
- package/lib/components/index.ts +7 -0
- package/lib/configs/subApp.ts +9 -0
- package/lib/entrance/libProperties.ts +5 -0
- package/lib/entrance/libTypes.ts +10 -0
- package/lib/index.tsx +36 -0
- package/lib/loadApp.tsx +20 -0
- package/lib/react-app-env.d.ts +71 -0
- package/lib/setupProxy.js +23 -0
- package/lib/setupTests.ts +5 -0
- package/package.json +131 -0
- package/scripts/build.js +217 -0
- package/scripts/check.js +13 -0
- package/scripts/meta.js +21 -0
- package/scripts/postinstall.js +10 -0
- package/scripts/prepublishOnly.js +28 -0
- package/scripts/replaceToRelativePath.js +31 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/components/HelloRemoteReactComp/App.css +50 -0
- package/src/components/HelloRemoteReactComp/App.test.tsx +10 -0
- package/src/components/HelloRemoteReactComp/App.tsx +37 -0
- package/src/components/HelloRemoteReactComp/index.css +13 -0
- package/src/components/HelloRemoteReactComp/index.tsx +4 -0
- package/src/components/HelloRemoteReactComp/logo.svg +1 -0
- package/src/components/index.ts +7 -0
- package/src/configs/subApp.ts +9 -0
- package/src/entrance/libProperties.ts +5 -0
- package/src/entrance/libTypes.ts +10 -0
- package/src/index.tsx +36 -0
- package/src/loadApp.tsx +20 -0
- package/src/react-app-env.d.ts +71 -0
- package/src/setupProxy.js +23 -0
- package/src/setupTests.ts +5 -0
- package/tsconfig.json +28 -0
package/scripts/start.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
4
|
+
process.env.BABEL_ENV = 'development';
|
|
5
|
+
process.env.NODE_ENV = 'development';
|
|
6
|
+
|
|
7
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
8
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
9
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
10
|
+
process.on('unhandledRejection', err => {
|
|
11
|
+
throw err;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Ensure environment variables are read.
|
|
15
|
+
require('../config/env');
|
|
16
|
+
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const chalk = require('react-dev-utils/chalk');
|
|
19
|
+
const webpack = require('webpack');
|
|
20
|
+
const WebpackDevServer = require('webpack-dev-server');
|
|
21
|
+
const clearConsole = require('react-dev-utils/clearConsole');
|
|
22
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
23
|
+
const {
|
|
24
|
+
choosePort,
|
|
25
|
+
createCompiler,
|
|
26
|
+
prepareProxy,
|
|
27
|
+
prepareUrls,
|
|
28
|
+
} = require('react-dev-utils/WebpackDevServerUtils');
|
|
29
|
+
const openBrowser = require('react-dev-utils/openBrowser');
|
|
30
|
+
const semver = require('semver');
|
|
31
|
+
const paths = require('../config/paths');
|
|
32
|
+
const configFactory = require('../config/webpack.config');
|
|
33
|
+
const createDevServerConfig = require('../config/webpackDevServer.config');
|
|
34
|
+
const getClientEnvironment = require('../config/env');
|
|
35
|
+
const react = require(require.resolve('react', { paths: [paths.appPath] }));
|
|
36
|
+
|
|
37
|
+
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
|
|
38
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
39
|
+
const isInteractive = process.stdout.isTTY;
|
|
40
|
+
|
|
41
|
+
// Warn and crash if required files are missing
|
|
42
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Tools like Cloud9 rely on this.
|
|
47
|
+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
|
48
|
+
const HOST = process.env.HOST || '0.0.0.0';
|
|
49
|
+
|
|
50
|
+
if (process.env.HOST) {
|
|
51
|
+
console.log(
|
|
52
|
+
chalk.cyan(
|
|
53
|
+
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
|
54
|
+
chalk.bold(process.env.HOST)
|
|
55
|
+
)}`
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
console.log(
|
|
59
|
+
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
|
60
|
+
);
|
|
61
|
+
console.log(
|
|
62
|
+
`Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}`
|
|
63
|
+
);
|
|
64
|
+
console.log();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// We require that you explicitly set browsers and do not fall back to
|
|
68
|
+
// browserslist defaults.
|
|
69
|
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
70
|
+
checkBrowsers(paths.appPath, isInteractive)
|
|
71
|
+
.then(() => {
|
|
72
|
+
// We attempt to use the default port but if it is busy, we offer the user to
|
|
73
|
+
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
|
74
|
+
return choosePort(HOST, DEFAULT_PORT);
|
|
75
|
+
})
|
|
76
|
+
.then(port => {
|
|
77
|
+
if (port == null) {
|
|
78
|
+
// We have not found a port.
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const config = configFactory('development');
|
|
83
|
+
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
|
84
|
+
const appName = require(paths.appPackageJson).name;
|
|
85
|
+
|
|
86
|
+
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
|
87
|
+
const urls = prepareUrls(
|
|
88
|
+
protocol,
|
|
89
|
+
HOST,
|
|
90
|
+
port,
|
|
91
|
+
paths.publicUrlOrPath.slice(0, -1)
|
|
92
|
+
);
|
|
93
|
+
// Create a webpack compiler that is configured with custom messages.
|
|
94
|
+
const compiler = createCompiler({
|
|
95
|
+
appName,
|
|
96
|
+
config,
|
|
97
|
+
urls,
|
|
98
|
+
useYarn,
|
|
99
|
+
useTypeScript,
|
|
100
|
+
webpack,
|
|
101
|
+
});
|
|
102
|
+
// Load proxy config
|
|
103
|
+
const proxySetting = require(paths.appPackageJson).proxy;
|
|
104
|
+
const proxyConfig = prepareProxy(
|
|
105
|
+
proxySetting,
|
|
106
|
+
paths.appPublic,
|
|
107
|
+
paths.publicUrlOrPath
|
|
108
|
+
);
|
|
109
|
+
// Serve webpack assets generated by the compiler over a web server.
|
|
110
|
+
const serverConfig = {
|
|
111
|
+
...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
|
|
112
|
+
host: HOST,
|
|
113
|
+
port,
|
|
114
|
+
};
|
|
115
|
+
const devServer = new WebpackDevServer(serverConfig, compiler);
|
|
116
|
+
// Launch WebpackDevServer.
|
|
117
|
+
devServer.startCallback(() => {
|
|
118
|
+
if (isInteractive) {
|
|
119
|
+
clearConsole();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
|
|
123
|
+
console.log(
|
|
124
|
+
chalk.yellow(
|
|
125
|
+
`Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log(chalk.cyan('Starting the development server...\n'));
|
|
131
|
+
openBrowser(urls.localUrlForBrowser);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
['SIGINT', 'SIGTERM'].forEach(function (sig) {
|
|
135
|
+
process.on(sig, function () {
|
|
136
|
+
devServer.close();
|
|
137
|
+
process.exit();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (process.env.CI !== 'true') {
|
|
142
|
+
// Gracefully exit when stdin ends
|
|
143
|
+
process.stdin.on('end', function () {
|
|
144
|
+
devServer.close();
|
|
145
|
+
process.exit();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
.catch(err => {
|
|
150
|
+
if (err && err.message) {
|
|
151
|
+
console.log(err.message);
|
|
152
|
+
}
|
|
153
|
+
process.exit(1);
|
|
154
|
+
});
|
package/scripts/test.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
4
|
+
process.env.BABEL_ENV = 'test';
|
|
5
|
+
process.env.NODE_ENV = 'test';
|
|
6
|
+
process.env.PUBLIC_URL = '';
|
|
7
|
+
|
|
8
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
9
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
10
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
11
|
+
process.on('unhandledRejection', err => {
|
|
12
|
+
throw err;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ensure environment variables are read.
|
|
16
|
+
require('../config/env');
|
|
17
|
+
|
|
18
|
+
const jest = require('jest');
|
|
19
|
+
const execSync = require('child_process').execSync;
|
|
20
|
+
let argv = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
function isInGitRepository() {
|
|
23
|
+
try {
|
|
24
|
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
|
25
|
+
return true;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isInMercurialRepository() {
|
|
32
|
+
try {
|
|
33
|
+
execSync('hg --cwd . root', { stdio: 'ignore' });
|
|
34
|
+
return true;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Watch unless on CI or explicitly running all tests
|
|
41
|
+
if (
|
|
42
|
+
!process.env.CI &&
|
|
43
|
+
argv.indexOf('--watchAll') === -1 &&
|
|
44
|
+
argv.indexOf('--watchAll=false') === -1
|
|
45
|
+
) {
|
|
46
|
+
// https://github.com/facebook/create-react-app/issues/5210
|
|
47
|
+
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
|
48
|
+
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
jest.run(argv);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* @helstart hel-tpl-remote-react-comps-ts @helend */
|
|
2
|
+
/* TODO: use webpack style plugin to mark where the style content comes from */
|
|
3
|
+
body {
|
|
4
|
+
background-color: blue;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.App {
|
|
8
|
+
text-align: center;
|
|
9
|
+
border: 23px solid red;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.MarkRemotComp {
|
|
13
|
+
background-color: red;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.App-logo {
|
|
17
|
+
height: 40vmin;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
22
|
+
.App-logo {
|
|
23
|
+
animation: App-logo-spin infinite 20s linear;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.App-header {
|
|
28
|
+
background-color: #282c34;
|
|
29
|
+
min-height: 100vh;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
font-size: calc(10px + 2vmin);
|
|
35
|
+
color: white;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.App-link {
|
|
39
|
+
color: #61dafb;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@keyframes App-logo-spin {
|
|
43
|
+
from {
|
|
44
|
+
transform: rotate(0deg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
to {
|
|
48
|
+
transform: rotate(360deg);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import App from './App';
|
|
4
|
+
|
|
5
|
+
test('renders learn hel-micro link', () => {
|
|
6
|
+
render(<App />);
|
|
7
|
+
const linkElement = screen.getByText(/Learn hel-micro/i);
|
|
8
|
+
// TO BE FIXED: no toBeInTheDocument property in pnpm
|
|
9
|
+
expect(linkElement).toBeInTheDocument();
|
|
10
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import logo from './logo.svg';
|
|
3
|
+
import './App.css';
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
onHeaderClick?: (label: string) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const App = React.forwardRef(function App(props: IProps, ref: any) {
|
|
11
|
+
React.useImperativeHandle(ref, () => ({
|
|
12
|
+
sayHello() {
|
|
13
|
+
alert('Hello');
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
return (
|
|
17
|
+
<div className="App">
|
|
18
|
+
<header className="App-header" onClick={() => props.onHeaderClick?.('header click')}>
|
|
19
|
+
<img src={logo} className="App-logo" alt="logo" />
|
|
20
|
+
<p>
|
|
21
|
+
<h1>This is a hel remote react component (ts)!www eee</h1>
|
|
22
|
+
<h2>emitted by hel-micro</h2>
|
|
23
|
+
</p>
|
|
24
|
+
<a
|
|
25
|
+
className="App-link"
|
|
26
|
+
href="https://www.baidu.com"
|
|
27
|
+
target="_blank"
|
|
28
|
+
rel="noopener noreferrer"
|
|
29
|
+
>
|
|
30
|
+
Learn hel-micro
|
|
31
|
+
</a>
|
|
32
|
+
</header>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export default App;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
code {
|
|
11
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
+
monospace;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LibProperties } from './libProperties';
|
|
2
|
+
import { exposeLib } from 'hel-lib-proxy';
|
|
3
|
+
import { LIB_NAME } from 'configs/subApp';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const lib = exposeLib<LibProperties>(LIB_NAME);
|
|
7
|
+
|
|
8
|
+
export type Lib = LibProperties;
|
|
9
|
+
|
|
10
|
+
export default lib;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|--------------------------------------------------------------------------
|
|
3
|
+
|
|
|
4
|
+
| 应用可能使用了头部 import 静态导入语法来使用hel模块,所以此处
|
|
5
|
+
| 将应用入口文件后移一层到 loadApp 里并使用 import() 函数载入,这样以后
|
|
6
|
+
| entrance/libProperties 和 loadApp 模块下有其他远程模块依赖且想在整个项目使用静态导入时,
|
|
7
|
+
| 可在此文件main 函数里使用 helMicro.preFetchLib 来提前加载别的远程依赖,
|
|
8
|
+
|
|
|
9
|
+
| @author: fantasticsoul
|
|
10
|
+
| @date: 2022-06-05
|
|
11
|
+
|--------------------------------------------------------------------------
|
|
12
|
+
*/
|
|
13
|
+
// import { preFetchLib } from 'hel-micro';
|
|
14
|
+
import { isMasterApp } from 'hel-iso';
|
|
15
|
+
import { libReady } from 'hel-lib-proxy';
|
|
16
|
+
import { LIB_NAME } from './configs/subApp';
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
// 如有其他包依赖,且需要在逻辑里静态导入,可在此处执行预抓取
|
|
20
|
+
// await helMicro.preFetchLib('other-lib');
|
|
21
|
+
|
|
22
|
+
const libProperties = await import('./entrance/libProperties');
|
|
23
|
+
console.log('libProperties', libProperties);
|
|
24
|
+
// 表示模块已准备就绪,注意此处传递的是 default
|
|
25
|
+
libReady(LIB_NAME, libProperties.default);
|
|
26
|
+
|
|
27
|
+
// 非子应用时(即不是被别的模块触发载入的情况),自己挂载渲染节点,方便本地调试
|
|
28
|
+
if (isMasterApp()) {
|
|
29
|
+
await import('./loadApp');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main().catch(console.error);
|
|
34
|
+
|
|
35
|
+
// avoid isolatedModules warning
|
|
36
|
+
export default 'Hel Module Index file';
|
package/src/loadApp.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import comps from 'components';
|
|
5
|
+
|
|
6
|
+
function getHostNode(id = 'root') {
|
|
7
|
+
let node = document.getElementById(id);
|
|
8
|
+
if (!node) {
|
|
9
|
+
node = document.createElement('div');
|
|
10
|
+
node.id = id;
|
|
11
|
+
document.body.appendChild(node);
|
|
12
|
+
}
|
|
13
|
+
return node;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { REACT_APP_COMP_TYPE = 'HelloRemoteReactComp' } = process.env;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const Comp = comps[REACT_APP_COMP_TYPE] || (() => <h1>comp {REACT_APP_COMP_TYPE} not defined</h1>);
|
|
19
|
+
|
|
20
|
+
ReactDOM.render(<Comp />, getHostNode('root'));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
/// <reference types="react-dom" />
|
|
4
|
+
|
|
5
|
+
declare namespace NodeJS {
|
|
6
|
+
interface ProcessEnv {
|
|
7
|
+
readonly NODE_ENV: 'development' | 'production' | 'test';
|
|
8
|
+
readonly PUBLIC_URL: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '*.avif' {
|
|
13
|
+
const src: string;
|
|
14
|
+
export default src;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module '*.bmp' {
|
|
18
|
+
const src: string;
|
|
19
|
+
export default src;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const src: string;
|
|
24
|
+
export default src;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '*.jpg' {
|
|
28
|
+
const src: string;
|
|
29
|
+
export default src;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare module '*.jpeg' {
|
|
33
|
+
const src: string;
|
|
34
|
+
export default src;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module '*.png' {
|
|
38
|
+
const src: string;
|
|
39
|
+
export default src;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare module '*.webp' {
|
|
43
|
+
const src: string;
|
|
44
|
+
export default src;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare module '*.svg' {
|
|
48
|
+
import * as React from 'react';
|
|
49
|
+
|
|
50
|
+
export const ReactComponent: React.FunctionComponent<React.SVGProps<
|
|
51
|
+
SVGSVGElement
|
|
52
|
+
> & { title?: string }>;
|
|
53
|
+
|
|
54
|
+
const src: string;
|
|
55
|
+
export default src;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare module '*.module.css' {
|
|
59
|
+
const classes: { readonly [key: string]: string };
|
|
60
|
+
export default classes;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.module.scss' {
|
|
64
|
+
const classes: { readonly [key: string]: string };
|
|
65
|
+
export default classes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module '*.module.sass' {
|
|
69
|
+
const classes: { readonly [key: string]: string };
|
|
70
|
+
export default classes;
|
|
71
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 配置 proxy, 代理到本地启动的mocker服务
|
|
5
|
+
* 这份文件是CRA读取的,不属于项目打包后会包含的代码,所以非ts后缀
|
|
6
|
+
*/
|
|
7
|
+
const { createProxyMiddleware: proxy } = require('http-proxy-middleware');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function makeProxyConfig(target) {
|
|
11
|
+
return {
|
|
12
|
+
target,
|
|
13
|
+
secure: false,
|
|
14
|
+
changeOrigin: true,
|
|
15
|
+
withCredentials: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// 如当前组件本地调试时需要发起的请求被代理出去,可配置此文件
|
|
21
|
+
module.exports = function (app) {
|
|
22
|
+
app.use(proxy('/somepath', makeProxyConfig('https://xxx.yyy.com')));
|
|
23
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "src",
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"outDir": "lib-js",
|
|
6
|
+
"noEmit": false,
|
|
7
|
+
"lib": [
|
|
8
|
+
"dom",
|
|
9
|
+
"dom.iterable",
|
|
10
|
+
"esnext"
|
|
11
|
+
],
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"allowSyntheticDefaultImports": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
|
19
|
+
"module": "esnext",
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"resolveJsonModule": true,
|
|
22
|
+
"isolatedModules": true,
|
|
23
|
+
"jsx": "react-jsx"
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"src"
|
|
27
|
+
]
|
|
28
|
+
}
|