Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fc414b

Browse files
committed
init commit
1 parent 069e428 commit 9fc414b

File tree

5,240 files changed

+401144
-1240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,240 files changed

+401144
-1240
lines changed

viewer/README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Lowcoder frontend
2+
3+
## How to contribute
4+
5+
### Start a local backend server
6+
7+
#### Use prebuilt docker image
8+
9+
Simply run the below command to start a backend server.
10+
11+
```bash
12+
docker run -d --name lowcoder -p 3000:3000 -v "$PWD/stacks:/lowcoder-stacks" lowcoderorg/lowcoder-ce
13+
```
14+
15+
For more information, view our [docs](https://docs.lowcoder.cloud/lowcoder-documentation/setup-and-run/self-hosting)
16+
17+
#### Build Docker image from source
18+
19+
1. Check out the source code and change to source dir.
20+
2. Use the command below to build a Docker image :
21+
22+
```bash
23+
docker build -f ./deploy/docker/Dockerfile -t lowcoder-dev .
24+
```
25+
26+
3. Start
27+
28+
```bash
29+
docker run -d --name lowcoder-dev -p 3000:3000 -v "$PWD/stacks:/lowcoder-stacks" lowcoder-dev
30+
```
31+
32+
### Start develop
33+
34+
35+
1. Check out source code.
36+
2. Change to **/client** dir in the source dir.
37+
38+
```bash
39+
cd client
40+
```
41+
3. Run yarn to install dependencies.
42+
43+
```bash
44+
yarn install
45+
```
46+
47+
4. Start dev server:
48+
49+
```bash
50+
LOWCODER_API_SERVICE_URL=http://localhost:3000 yarn start
51+
```
52+
53+
5. After dev server starts successfully, it will be automatically opened in the default browser.
54+
55+
### Before submitting a pull request
56+
57+
In addition, before submitting a pull request, please make sure the following is done:
58+
59+
1. If you’ve fixed a bug or added code that should be tested and add unit test suite.
60+
2. Run test and ensure all test suites pass.
61+
62+
```bash
63+
yarn test
64+
```
65+
66+
3. If you add new dependency, use the yarn worspace tool to make sure yarn.lock is also updated.
67+
68+
```bash
69+
yarn workspace lowcoder <package name>
70+
```
71+
72+
### Developing and publishung UI components for Lowcoder
73+
74+
1. Initialization
75+
76+
Project initiation
77+
78+
```bash
79+
yarn create Lowcoder-plugin <your plugin name>
80+
```
81+
82+
Go to the project root
83+
84+
```bash
85+
cd my-plugin
86+
```
87+
88+
Start the development environment
89+
90+
```bash
91+
yarn start
92+
```
93+
94+
After executing yarn start, the browser is automatically opened and you enter the component development environment.
95+
Please find more information in our [docs](https://docs.lowcoder.cloud/lowcoder-documentation/lowcoder-extension/develop-ui-components-for-apps)
96+
97+
2. Export components
98+
99+
To export all the components, use src/index.ts, for example:
100+
101+
```bash
102+
import HelloWorldComp from "./HelloWorldComp";
103+
104+
export default {
105+
hello_world: HelloWorldComp,
106+
};
107+
```
108+
109+
import HelloWorldComp from "./HelloWorldComp";
110+
111+
3. Publish plugins
112+
113+
When you finish developing and testing the plugin, you can publish it into the npm registry. Login in to the npm registry locally, and then execute the following command:
114+
115+
```bash
116+
yarn build --publish
117+
```
118+
119+
You can check a code demo here: [Code Demo on Github](https://github.com/lowcoder-org/lowcoder/tree/main/client/packages/lowcoder-plugin-demo)

viewer/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.4.5

viewer/config/test/jest.config.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import path, { dirname } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { buildVars } from "../../scripts/buildVars.js";
4+
5+
export function currentDirName(importMetaUrl) {
6+
return dirname(fileURLToPath(importMetaUrl));
7+
}
8+
9+
const globals = {};
10+
buildVars.forEach(({ name, defaultValue }) => {
11+
globals[name] = process.env[name] || defaultValue;
12+
});
13+
const currentDir = currentDirName(import.meta.url);
14+
15+
export default {
16+
testEnvironment: "jsdom",
17+
moduleNameMapper: {
18+
"react-markdown": path.resolve(currentDir, "./mocks/react-markdown.js"),
19+
"\\.md\\?url$": path.resolve(currentDir, "./mocks/markdown-url-module.js"),
20+
"^@lowcoder-ee(.*)$": path.resolve(
21+
currentDir, "../../packages/lowcoder/src/$1"
22+
),
23+
"lowcoder-sdk": path.resolve(currentDir, "../../packages/lowcoder/src/index.sdk"),
24+
},
25+
globals,
26+
// roots: ["<rootDir>/src"],
27+
modulePaths: [
28+
"<rootDir>/src",
29+
path.resolve(currentDir, "../../packages/lowcoder/src"),
30+
path.resolve(currentDir, "../../packages/lowcoder-comps/src"),
31+
path.resolve(currentDir, "../../packages/lowcoder-design/src"),
32+
],
33+
setupFiles: [path.resolve(currentDir, "./jest.setup.js")],
34+
setupFilesAfterEnv: [path.resolve(currentDir, "./jest.setup-after-env.js"), 'jest-canvas-mock'],
35+
transform: {
36+
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": path.resolve(currentDir, "./transform/babelTransform.js"),
37+
"^.+\\.css$": path.resolve(currentDir, "./transform/cssTransform.js"),
38+
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": path.resolve(
39+
currentDir,
40+
"./transform/fileTransform.js"
41+
),
42+
},
43+
transformIgnorePatterns: [],
44+
resetMocks: true,
45+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import "@testing-library/jest-dom";
6+
7+
// implementation of window.resizeTo for dispatching event
8+
window.resizeTo = function resizeTo(width, height) {
9+
Object.assign(this, {
10+
innerWidth: width,
11+
innerHeight: height,
12+
outerWidth: width,
13+
outerHeight: height,
14+
}).dispatchEvent(new this.Event("resize"));
15+
};
16+
17+
window.ResizeObserver = function () {
18+
return {
19+
observe: () => {},
20+
unobserve: () => {},
21+
disconnect: () => {},
22+
};
23+
};
24+
25+
Object.defineProperty(window, 'ImageData', { value: 'yourValue' });
26+
Object.defineProperty(window, 'MediaStreamTrack', { value: 'yourValue' });
27+
Object.defineProperty(window, 'URL', {
28+
writable: true,
29+
value: {
30+
createObjectURL: jest.fn(),
31+
}
32+
});
33+
Object.defineProperty(window, "navigator", {
34+
writable: true,
35+
value: {
36+
mediaDevices: {
37+
enumerateDevices: jest.fn(),
38+
},
39+
userAgent: '',
40+
language: '',
41+
browserLanguage: '',
42+
},
43+
});
44+
45+
class Worker {
46+
constructor(stringUrl) {
47+
this.url = stringUrl;
48+
this.onmessage = () => {};
49+
}
50+
51+
postMessage(msg) {
52+
this.onmessage(msg);
53+
}
54+
}
55+
56+
window.Worker = Worker;

viewer/config/test/jest.setup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (typeof window !== "undefined") {
2+
require("whatwg-fetch");
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function ReactMarkdown({ children }) {
2+
return <>{children}</>;
3+
}
4+
5+
export default ReactMarkdown;

viewer/config/test/setup.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import "@testing-library/jest-dom";
6+
7+
// import matchMediaPolyfill from "mq-polyfill";
8+
9+
// matchMediaPolyfill(window);
10+
// // implementation of window.resizeTo for dispatching event
11+
// window.resizeTo = function resizeTo(width, height) {
12+
// Object.assign(this, {
13+
// innerWidth: width,
14+
// innerHeight: height,
15+
// outerWidth: width,
16+
// outerHeight: height,
17+
// }).dispatchEvent(new this.Event("resize"));
18+
// };
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import babelJest from "babel-jest";
2+
3+
export default babelJest.createTransformer({
4+
presets: [
5+
[
6+
"babel-preset-react-app",
7+
{
8+
runtime: "automatic",
9+
},
10+
],
11+
],
12+
babelrc: false,
13+
configFile: false,
14+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This is a custom Jest transformer turning style imports into empty objects.
2+
// http://facebook.github.io/jest/docs/en/webpack.html
3+
4+
export default {
5+
process() {
6+
return {
7+
code: "module.exports = {};",
8+
};
9+
},
10+
getCacheKey() {
11+
// The output is always the same.
12+
return {
13+
code: "cssTransform",
14+
};
15+
},
16+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import path from "node:path";
2+
import camelcase from "camelcase";
3+
4+
// This is a custom Jest transformer turning file imports into filenames.
5+
// http://facebook.github.io/jest/docs/en/webpack.html
6+
7+
export default {
8+
process(src, filename) {
9+
const assetFilename = JSON.stringify(path.basename(filename));
10+
11+
if (filename.match(/\.svg$/)) {
12+
// Based on how SVGR generates a component name:
13+
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
14+
const pascalCaseFilename = camelcase(path.parse(filename).name, {
15+
pascalCase: true,
16+
});
17+
const componentName = `Svg${pascalCaseFilename}`;
18+
return {
19+
code: `
20+
const React = require('react');
21+
module.exports = {
22+
__esModule: true,
23+
default: ${assetFilename},
24+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25+
return {
26+
$$typeof: Symbol.for('react.element'),
27+
type: 'svg',
28+
ref: ref,
29+
key: null,
30+
props: Object.assign({}, props, {
31+
children: ${assetFilename}
32+
})
33+
};
34+
}),
35+
};`,
36+
};
37+
}
38+
39+
return {
40+
code: `module.exports = ${assetFilename};`,
41+
};
42+
},
43+
};

viewer/netlify.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[[redirects]]
2+
from = "/*"
3+
to = "/"
4+
status = 200

viewer/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-root",
3-
"version": "2.4.5",
3+
"version": "2.3.1",
44
"type": "module",
55
"private": true,
66
"workspaces": [
@@ -48,6 +48,7 @@
4848
"jest-canvas-mock": "^2.5.2",
4949
"jest-environment-jsdom": "^29.5.0",
5050
"lint-staged": "^13.0.1",
51+
"lowcoder-cli": "workspace:^",
5152
"mq-polyfill": "^1.1.8",
5253
"prettier": "^3.1.0",
5354
"rimraf": "^3.0.2",
@@ -79,6 +80,7 @@
7980
"chalk": "4",
8081
"flag-icons": "^7.2.1",
8182
"number-precision": "^1.6.0",
83+
"posthog-js": "^1.144.2",
8284
"react-countup": "^6.5.3",
8385
"react-player": "^2.11.0",
8486
"resize-observer-polyfill": "^1.5.1",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.tgz
2+
.DS_Store
3+
node_modules
4+
*.zip

0 commit comments

Comments
 (0)