anu-verzum 1.18.1 → 1.20.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 +13 -40
- package/dist/index.d.ts +3 -0
- package/dist/server-api/server-api.d.ts +3 -0
- package/dist/server-api/server-api.js +12 -5
- package/package.json +10 -4
- package/webpack.config.js +36 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h3>@author: <strong>Anubis-programmer</strong></h3>
|
|
6
6
|
<h3>@license: <strong>MIT</strong></h3>
|
|
7
|
-
<h3>@version: <strong>1.
|
|
7
|
+
<h3>@version: <strong>1.20.0</strong></h3>
|
|
8
8
|
|
|
9
9
|
<br>
|
|
10
10
|
|
|
@@ -46,47 +46,10 @@ Create a `babel.config.json` in your project root:
|
|
|
46
46
|
|
|
47
47
|
<h3 id="webpack-setup">Webpack setup</h3>
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin babel-loader @babel/core @babel/preset-env
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Create (or update) `webpack.config.js`:
|
|
49
|
+
All build tools ship with `anu-verzum` — no separate install needed. Create `webpack.config.js` in your project root:
|
|
56
50
|
|
|
57
51
|
```js
|
|
58
|
-
|
|
59
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
60
|
-
|
|
61
|
-
module.exports = {
|
|
62
|
-
mode: 'development',
|
|
63
|
-
entry: './src/index.tsx', // use index.js for JavaScript-only projects
|
|
64
|
-
output: {
|
|
65
|
-
path: path.resolve(__dirname, 'dist'),
|
|
66
|
-
filename: 'bundle.js',
|
|
67
|
-
publicPath: '/'
|
|
68
|
-
},
|
|
69
|
-
module: {
|
|
70
|
-
rules: [
|
|
71
|
-
{
|
|
72
|
-
test: /\.[jt]sx?$/, // use /\.jsx?$/ for JavaScript-only projects
|
|
73
|
-
exclude: /node_modules/,
|
|
74
|
-
use: 'babel-loader'
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
resolve: {
|
|
79
|
-
extensions: ['.js', '.jsx', '.tsx', '.ts']
|
|
80
|
-
},
|
|
81
|
-
plugins: [
|
|
82
|
-
new HtmlWebpackPlugin({ template: './index.html' })
|
|
83
|
-
],
|
|
84
|
-
devServer: {
|
|
85
|
-
port: 3000,
|
|
86
|
-
historyApiFallback: true,
|
|
87
|
-
open: true
|
|
88
|
-
}
|
|
89
|
-
};
|
|
52
|
+
module.exports = require('anu-verzum/webpack.config')(__dirname);
|
|
90
53
|
```
|
|
91
54
|
|
|
92
55
|
Add scripts to `package.json`:
|
|
@@ -100,6 +63,16 @@ Add scripts to `package.json`:
|
|
|
100
63
|
}
|
|
101
64
|
```
|
|
102
65
|
|
|
66
|
+
The default config targets `src/index.tsx` as the entry point and `index.html` as the HTML template, served on port 3000. Pass an options object to override any of these:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
module.exports = require('anu-verzum/webpack.config')(__dirname, {
|
|
70
|
+
entry: './src/main.tsx',
|
|
71
|
+
template: './public/index.html',
|
|
72
|
+
port: 4000
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
103
76
|
<h3 id="importing-in-your-files">Importing in your files</h3>
|
|
104
77
|
|
|
105
78
|
Every file that contains JSX must import `Anu`, because the JSX transform expands to `Anu.createElement(...)` calls at compile time:
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,9 @@ declare const Anu: {
|
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
118
|
ServerAPI: {
|
|
119
|
+
configure: ({ baseURL }: {
|
|
120
|
+
baseURL?: string;
|
|
121
|
+
}) => void;
|
|
119
122
|
get: <T = any>(url: string, params?: Record<string, any>) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
120
123
|
post: <T = any>(url: string, data: unknown) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
121
124
|
put: <T = any>(url: string, data: unknown) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
@@ -7,6 +7,9 @@ export type ApiErrorResponse = {
|
|
|
7
7
|
response: null;
|
|
8
8
|
};
|
|
9
9
|
declare const ServerAPI: {
|
|
10
|
+
configure: ({ baseURL }: {
|
|
11
|
+
baseURL?: string;
|
|
12
|
+
}) => void;
|
|
10
13
|
get: <T = any>(url: string, params?: Record<string, any>) => Promise<ApiSuccessResponse<T>>;
|
|
11
14
|
post: <T = any>(url: string, data: unknown) => Promise<ApiSuccessResponse<T>>;
|
|
12
15
|
put: <T = any>(url: string, data: unknown) => Promise<ApiSuccessResponse<T>>;
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
let _baseURL = '';
|
|
8
|
+
const _resolveURL = url => /^https?:\/\//.test(url) ? url : `${_baseURL}${url}`;
|
|
7
9
|
const SUCCESS_STATUS_CODES = [200, 201, 202, 203, 204, 205, 206, 207, 208, 226];
|
|
8
10
|
const CLIENT_ERROR_STATUS_CODES = [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451];
|
|
9
11
|
const SERVER_ERROR_STATUS_CODES = [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511];
|
|
@@ -105,10 +107,15 @@ const _serverFileAPI = (url, files, data = {}) => (successHandler, errorHandler)
|
|
|
105
107
|
XHR.send(formData);
|
|
106
108
|
};
|
|
107
109
|
const ServerAPI = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
configure: ({
|
|
111
|
+
baseURL = ''
|
|
112
|
+
}) => {
|
|
113
|
+
_baseURL = baseURL.replace(/\/$/, '');
|
|
114
|
+
},
|
|
115
|
+
get: (url, params) => new Promise(_serverGetAPI(_resolveURL(url), params)),
|
|
116
|
+
post: (url, data) => new Promise(_serverPostAPI(_resolveURL(url), data)),
|
|
117
|
+
put: (url, data) => new Promise(_serverPutAPI(_resolveURL(url), data)),
|
|
118
|
+
delete: (url, params) => new Promise(_serverDeleteAPI(_resolveURL(url), params)),
|
|
119
|
+
file: (url, files, data) => new Promise(_serverFileAPI(_resolveURL(url), files, data))
|
|
113
120
|
};
|
|
114
121
|
var _default = exports.default = ServerAPI;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anu-verzum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "A \"React-like\" UI library that supports JSX syntax, Redux-like state management, array-rendering, i18n, routing and many more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anu-verzum",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
],
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"babel-preset.js"
|
|
16
|
+
"babel-preset.js",
|
|
17
|
+
"webpack.config.js"
|
|
17
18
|
],
|
|
18
19
|
"homepage": "https://github.com/Anubis-programmer/ANUVerzum#readme",
|
|
19
20
|
"bugs": {
|
|
@@ -39,12 +40,17 @@
|
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@babel/plugin-transform-react-jsx": "^7.21.0",
|
|
42
|
-
"@babel/plugin-transform-typescript": "^7.28.6"
|
|
43
|
+
"@babel/plugin-transform-typescript": "^7.28.6",
|
|
44
|
+
"@babel/preset-env": "^7.21.0",
|
|
45
|
+
"babel-loader": "^9.0.0",
|
|
46
|
+
"html-webpack-plugin": "^5.0.0",
|
|
47
|
+
"webpack": "^5.0.0",
|
|
48
|
+
"webpack-cli": "^5.0.0",
|
|
49
|
+
"webpack-dev-server": "^5.0.0"
|
|
43
50
|
},
|
|
44
51
|
"devDependencies": {
|
|
45
52
|
"@babel/cli": "^7.21.0",
|
|
46
53
|
"@babel/core": "^7.21.0",
|
|
47
|
-
"@babel/preset-env": "^7.21.0",
|
|
48
54
|
"@babel/preset-typescript": "^7.28.5",
|
|
49
55
|
"@eslint/js": "^10.0.1",
|
|
50
56
|
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
|
+
|
|
6
|
+
module.exports = (projectRoot, options = {}) => ({
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: options.entry ?? path.join(projectRoot, 'src/index.tsx'),
|
|
9
|
+
output: {
|
|
10
|
+
path: path.join(projectRoot, 'dist'),
|
|
11
|
+
filename: 'bundle.js',
|
|
12
|
+
publicPath: '/'
|
|
13
|
+
},
|
|
14
|
+
module: {
|
|
15
|
+
rules: [
|
|
16
|
+
{
|
|
17
|
+
test: /\.[jt]sx?$/,
|
|
18
|
+
exclude: /node_modules/,
|
|
19
|
+
use: 'babel-loader'
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
resolve: {
|
|
24
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
25
|
+
},
|
|
26
|
+
plugins: [
|
|
27
|
+
new HtmlWebpackPlugin({
|
|
28
|
+
template: options.template ?? path.join(projectRoot, 'index.html')
|
|
29
|
+
})
|
|
30
|
+
],
|
|
31
|
+
devServer: {
|
|
32
|
+
port: options.port ?? 3000,
|
|
33
|
+
historyApiFallback: true,
|
|
34
|
+
open: true
|
|
35
|
+
}
|
|
36
|
+
});
|