@m4l/core 0.0.0 → 0.0.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/{lib/contexts → contexts}/EnvironmentContext/index.d.ts +0 -0
- package/dist/{lib/contexts → contexts}/EnvironmentContext/types.d.ts +0 -0
- package/dist/contexts/FlagsContext/index.d.ts +5 -0
- package/dist/contexts/FlagsContext/types.d.ts +10 -0
- package/dist/{lib/contexts → contexts}/HostToolsContext/index.d.ts +0 -0
- package/dist/{lib/contexts → contexts}/HostToolsContext/types.d.ts +0 -0
- package/dist/contexts/ModuleDictionaryContext/index.d.ts +5 -0
- package/dist/contexts/ModuleDictionaryContext/types.d.ts +15 -0
- package/dist/{lib/contexts → contexts}/NetworkContext/index.d.ts +0 -0
- package/dist/{lib/contexts → contexts}/NetworkContext/types.d.ts +0 -0
- package/dist/{lib/contexts → contexts}/index.d.ts +2 -0
- package/dist/{lib/hooks → hooks}/index.d.ts +2 -0
- package/dist/{lib/hooks → hooks}/useEnvironment/index.d.ts +0 -0
- package/dist/hooks/useFlags/index.d.ts +3 -0
- package/dist/{lib/hooks → hooks}/useHostTools/index.d.ts +1 -1
- package/dist/{lib/hooks → hooks}/useLocalStorage/useLocalStorage.d.ts +0 -0
- package/dist/hooks/useModuleDictionary/index.d.ts +1 -0
- package/dist/{lib/hooks → hooks}/useNetwork/index.d.ts +0 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1567 -0
- package/dist/types/dictionary.d.ts +13 -0
- package/dist/{lib/types → types}/index.d.ts +0 -0
- package/dist/utils/axiosOperation/index.d.ts +2 -0
- package/dist/utils/axiosOperation/types.d.ts +5 -0
- package/dist/{lib/utils → utils}/getLocalStorage.d.ts +0 -0
- package/dist/{lib/utils → utils}/getPropertyByString.d.ts +0 -0
- package/dist/{lib/utils → utils}/index.d.ts +1 -0
- package/dist/{lib/utils → utils}/setLocalStorage.d.ts +0 -0
- package/dist/{lib/utils → utils}/voidFunction.d.ts +0 -0
- package/package.json +12 -18
- package/dist/lib/index.d.ts +0 -5
- package/dist/m4l_core.es.js +0 -114
- package/dist/manifest.json +0 -7
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type GetLabelType = (key: string) => string;
|
|
2
|
+
export interface ComponentDictionary {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Dictionary {
|
|
6
|
+
[key: string]: ComponentDictionary | boolean | undefined | string;
|
|
7
|
+
}
|
|
8
|
+
export interface DataDictionary extends ComponentDictionary {
|
|
9
|
+
module_name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ModuleDictionary extends Dictionary {
|
|
12
|
+
data: DataDictionary;
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "M4L Team",
|
|
7
7
|
"scripts": {
|
|
@@ -17,13 +17,8 @@
|
|
|
17
17
|
"coverage": "vitest run --coverage",
|
|
18
18
|
"Oldprepack": "json -f package.json -I -e \"delete this.devDependencies; delete this.dependencies\""
|
|
19
19
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"nprogress": "^0.2.0",
|
|
23
|
-
"react": "^17.0.0 || 18.x",
|
|
24
|
-
"react-dom": "^18.0.0",
|
|
25
|
-
"react-toastify": "^9.0.3",
|
|
26
|
-
"snakecase-keys": "^5.4.2"
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18"
|
|
27
22
|
},
|
|
28
23
|
"devDependencies": {
|
|
29
24
|
"@testing-library/jest-dom": "^5.16.4",
|
|
@@ -37,7 +32,7 @@
|
|
|
37
32
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
38
33
|
"@typescript-eslint/parser": "^5.27.1",
|
|
39
34
|
"@vitejs/plugin-react": "^1.3.0",
|
|
40
|
-
"
|
|
35
|
+
"axios": "^0.27.2",
|
|
41
36
|
"eslint": "^8.17.0",
|
|
42
37
|
"eslint-config-prettier": "^8.5.0",
|
|
43
38
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
@@ -47,32 +42,31 @@
|
|
|
47
42
|
"eslint-plugin-react": "^7.30.0",
|
|
48
43
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
49
44
|
"eslint-plugin-unused-imports": "^2.0.0",
|
|
45
|
+
"history": "^5.3.0",
|
|
50
46
|
"jsdom": "^20.0.0",
|
|
51
47
|
"json": "^11.0.0",
|
|
52
48
|
"prettier": "^2.6.2",
|
|
49
|
+
"react": "^18.2.0",
|
|
50
|
+
"react-dom": "^18.2.0",
|
|
51
|
+
"react-toastify": "^9.0.5",
|
|
53
52
|
"rollup-plugin-terser": "^7.0.2",
|
|
53
|
+
"snakecase-keys": "^5.4.2",
|
|
54
54
|
"typescript": "^4.6.3",
|
|
55
55
|
"vite": "^2.9.9",
|
|
56
56
|
"vite-plugin-dts": "^1.2.0",
|
|
57
57
|
"vite-plugin-mkcert": "^1.6.4",
|
|
58
58
|
"vitest": "^0.15.2"
|
|
59
59
|
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"react": "^17.0.0 || 18.x",
|
|
62
|
-
"react-dom": "^18.0.0",
|
|
63
|
-
"react-toastify": "^9.0.3"
|
|
64
|
-
},
|
|
65
60
|
"files": [
|
|
66
61
|
"dist"
|
|
67
62
|
],
|
|
68
|
-
"main": "./dist/
|
|
69
|
-
"module": "./dist/
|
|
63
|
+
"main": "./dist/index.js",
|
|
64
|
+
"module": "./dist/index.js",
|
|
70
65
|
"type": "module",
|
|
71
66
|
"types": "./dist/index.d.ts",
|
|
72
67
|
"exports": {
|
|
73
68
|
".": {
|
|
74
|
-
"import": "./dist/
|
|
75
|
-
"require": "./dist/m4l_core.umd.js"
|
|
69
|
+
"import": "./dist/index.js"
|
|
76
70
|
}
|
|
77
71
|
},
|
|
78
72
|
"sideEffects": false,
|
package/dist/lib/index.d.ts
DELETED
package/dist/m4l_core.es.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import { createContext, useContext, useState } from "react";
|
|
18
|
-
import "react/jsx-runtime";
|
|
19
|
-
const initialValue$2 = {
|
|
20
|
-
isLocalhost: true,
|
|
21
|
-
host: "",
|
|
22
|
-
domain_token: "",
|
|
23
|
-
host_api_local: "",
|
|
24
|
-
host_api_remote: "",
|
|
25
|
-
host_static_assets: "",
|
|
26
|
-
environment: ""
|
|
27
|
-
};
|
|
28
|
-
const EnvironmentContext = createContext(initialValue$2);
|
|
29
|
-
function voidFunction() {
|
|
30
|
-
}
|
|
31
|
-
function getPropertyByString(object, propString) {
|
|
32
|
-
let value = object;
|
|
33
|
-
const props = propString.split(".");
|
|
34
|
-
for (let index = 0; index < props.length; index += 1) {
|
|
35
|
-
if (props[index] === void 0)
|
|
36
|
-
break;
|
|
37
|
-
value = value[props[index]];
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
function getLocalStorage(key, initialValue2) {
|
|
42
|
-
try {
|
|
43
|
-
const item = window.localStorage.getItem(key);
|
|
44
|
-
return item !== null ? JSON.parse(item) : initialValue2;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return initialValue2;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function setLocalStorage(key, value) {
|
|
50
|
-
try {
|
|
51
|
-
const item = window.localStorage.getItem(key);
|
|
52
|
-
let newValue = item !== null ? JSON.parse(item) : {};
|
|
53
|
-
newValue = __spreadValues(__spreadValues({}, newValue), value);
|
|
54
|
-
window.localStorage.setItem(key, JSON.stringify(newValue));
|
|
55
|
-
} catch (e) {
|
|
56
|
-
console.error(e);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const initialValue$1 = {
|
|
60
|
-
toast: () => 0,
|
|
61
|
-
startProgress: voidFunction,
|
|
62
|
-
stopProgress: voidFunction,
|
|
63
|
-
events_add_listener: voidFunction,
|
|
64
|
-
events_remove_listener: voidFunction,
|
|
65
|
-
events_emit: voidFunction
|
|
66
|
-
};
|
|
67
|
-
const HostToolsContext = createContext(initialValue$1);
|
|
68
|
-
const useEnvironment = () => {
|
|
69
|
-
const context = useContext(EnvironmentContext);
|
|
70
|
-
if (!context)
|
|
71
|
-
throw new Error("useEnvironment context must be use inside EnvironmentContext");
|
|
72
|
-
return context;
|
|
73
|
-
};
|
|
74
|
-
const useHostTools = () => {
|
|
75
|
-
const context = useContext(HostToolsContext);
|
|
76
|
-
if (!context)
|
|
77
|
-
throw new Error("useHostTools context must be use inside HostToolsContext");
|
|
78
|
-
return context;
|
|
79
|
-
};
|
|
80
|
-
const initialValue = {
|
|
81
|
-
networkOperation: () => Promise.resolve()
|
|
82
|
-
};
|
|
83
|
-
const NetworkContext = createContext(initialValue);
|
|
84
|
-
function useLocalStorage(key, initialValue2) {
|
|
85
|
-
const [value, setValue] = useState(() => {
|
|
86
|
-
try {
|
|
87
|
-
const item = window.localStorage.getItem(key);
|
|
88
|
-
return item !== null ? JSON.parse(item) : initialValue2;
|
|
89
|
-
} catch (e) {
|
|
90
|
-
return initialValue2;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
const setValueInLocalStorage = (newValue) => {
|
|
94
|
-
try {
|
|
95
|
-
window.localStorage.setItem(key, JSON.stringify(newValue));
|
|
96
|
-
setValue(newValue);
|
|
97
|
-
} catch (e) {
|
|
98
|
-
console.error(e);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
return [value, setValueInLocalStorage];
|
|
102
|
-
}
|
|
103
|
-
const useNetwork = () => {
|
|
104
|
-
const context = useContext(NetworkContext);
|
|
105
|
-
if (!context)
|
|
106
|
-
throw new Error("useNetwork context must be use inside NetworkContext");
|
|
107
|
-
return context;
|
|
108
|
-
};
|
|
109
|
-
function fn(arr) {
|
|
110
|
-
const arr2 = [1, ...arr];
|
|
111
|
-
const a = __spreadValues({}, { A: 1 });
|
|
112
|
-
console.log(a, arr2);
|
|
113
|
-
}
|
|
114
|
-
export { EnvironmentContext, HostToolsContext, NetworkContext, fn, getLocalStorage, getPropertyByString, setLocalStorage, useEnvironment, useHostTools, useLocalStorage, useNetwork, voidFunction };
|