@m4l/core 0.0.21 → 0.0.24
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/.eslintignore +2 -0
- package/.eslintrc.cjs +109 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +26 -0
- package/.vscode/settings.json +50 -0
- package/README copy.md +0 -0
- package/index.html +13 -0
- package/package.json +2 -4
- package/package_with_dependicies.json +75 -0
- package/src/contexts/EnvironmentContext/index.tsx +37 -0
- package/{dist/contexts/EnvironmentContext/types.d.ts → src/contexts/EnvironmentContext/types.ts} +3 -1
- package/src/contexts/FlagsContext/index.tsx +50 -0
- package/src/contexts/FlagsContext/types.ts +16 -0
- package/src/contexts/HostToolsContext/index.tsx +34 -0
- package/{dist/contexts/HostToolsContext/types.d.ts → src/contexts/HostToolsContext/types.ts} +3 -1
- package/src/contexts/ModuleDictionaryContext/index.tsx +109 -0
- package/src/contexts/ModuleDictionaryContext/types.ts +18 -0
- package/src/contexts/NetworkContext/index.tsx +44 -0
- package/{dist/contexts/NetworkContext/types.d.ts → src/contexts/NetworkContext/types.ts} +6 -2
- package/src/contexts/index.ts +5 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useEnvironment/index.test.tsx +36 -0
- package/src/hooks/useEnvironment/index.ts +13 -0
- package/src/hooks/useFlags/index.ts +33 -0
- package/src/hooks/useHostTools/index.ts +13 -0
- package/src/hooks/useLocalStorage/index.ts +23 -0
- package/src/hooks/useModuleDictionary/index.ts +11 -0
- package/src/hooks/useNetwork/index.ts +13 -0
- package/src/index.ts +43 -0
- package/src/indexFlags.ts +1 -0
- package/src/isolation/App.tsx +24 -0
- package/src/main.tsx +10 -0
- package/src/prueba.d1.t1 +10 -0
- package/src/test/setup.ts +1 -0
- package/src/test/utils.tsx +20 -0
- package/{dist/types/dictionary.d.ts → src/types/dictionary.ts} +5 -1
- package/{dist/types/index.d.ts → src/types/index.ts} +20 -5
- package/src/utils/axiosOperation/index.ts +140 -0
- package/{dist/utils/axiosOperation/types.d.ts → src/utils/axiosOperation/types.ts} +1 -1
- package/src/utils/getLocalStorage.ts +8 -0
- package/src/utils/getPropertyByString.ts +10 -0
- package/{dist/utils/index.d.ts → src/utils/index.ts} +0 -0
- package/src/utils/setLocalStorage.ts +12 -0
- package/src/utils/voidFunction.ts +2 -0
- package/{dist → src}/vite-env.d.ts +0 -0
- package/tsconfig.json +37 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +178 -0
- package/dist/EnvironmentContext.js +0 -13
- package/dist/HostToolsContext.js +0 -13
- package/dist/NetworkContext.js +0 -9
- package/dist/axios.js +0 -1299
- package/dist/contexts/EnvironmentContext/index.d.ts +0 -5
- package/dist/contexts/HostToolsContext/index.d.ts +0 -6
- package/dist/contexts/NetworkContext/index.d.ts +0 -5
- package/dist/hooks/useEnvironment/index.d.ts +0 -2
- package/dist/hooks/useHostTools/index.d.ts +0 -2
- package/dist/hooks/useLocalStorage/index.d.ts +0 -1
- package/dist/hooks/useNetwork/index.d.ts +0 -2
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -13
- package/dist/snakecase-keys.js +0 -18
- package/dist/useEnvironment.js +0 -9
- package/dist/useHostTools.js +0 -9
- package/dist/useLocalStorage.js +0 -21
- package/dist/useNetwork.js +0 -9
- package/dist/utils/axiosOperation/index.d.ts +0 -2
- package/dist/utils/getLocalStorage.d.ts +0 -1
- package/dist/utils/getPropertyByString.d.ts +0 -1
- package/dist/utils/setLocalStorage.d.ts +0 -1
- package/dist/utils/voidFunction.d.ts +0 -1
- package/dist/vendor.js +0 -153
- package/dist/voidFunction.js +0 -3
package/vite.config.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
// import { dependencies } from './package.json';
|
|
6
|
+
// import { terser } from 'rollup-plugin-terser';
|
|
7
|
+
import mkcert from 'vite-plugin-mkcert';
|
|
8
|
+
|
|
9
|
+
// function renderChunks(deps: Record<string, string>) {
|
|
10
|
+
// const chunks = {};
|
|
11
|
+
|
|
12
|
+
// Object.keys(deps).forEach(key => {
|
|
13
|
+
// if (['axios', 'snakecase-keys', 'react-dom'].includes(key)) return;
|
|
14
|
+
// chunks[key] = [key];
|
|
15
|
+
// });
|
|
16
|
+
|
|
17
|
+
// //console.log('renderChunks', deps, chunks);
|
|
18
|
+
|
|
19
|
+
// return chunks;
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
function manualChunks(id: string, _api: any) {
|
|
23
|
+
//Contextos
|
|
24
|
+
|
|
25
|
+
if (id.includes('EnvironmentContext')) {
|
|
26
|
+
return 'contexts/EnvironmentContext/index';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (id.includes('HostToolsContext')) {
|
|
30
|
+
return 'contexts/HostToolsContext/index';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (id.includes('FlagsContext')) {
|
|
34
|
+
return 'contexts/FlagsContext/index';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (id.includes('NetworkContext')) {
|
|
38
|
+
return 'contexts/NetworkContext/index';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (id.includes('ModuleDictionaryContext')) {
|
|
42
|
+
return 'contexts/ModuleDictionaryContext/index';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//hooks
|
|
46
|
+
if (id.includes('useEnvironment')) {
|
|
47
|
+
return 'hooks/useEnvironment/index';
|
|
48
|
+
}
|
|
49
|
+
if (id.includes('useHostTools')) {
|
|
50
|
+
return 'hooks/useHostTools/index';
|
|
51
|
+
}
|
|
52
|
+
if (id.includes('useNetwork')) {
|
|
53
|
+
return 'hooks/useNetwork/index';
|
|
54
|
+
}
|
|
55
|
+
if (id.includes('useFlags')) {
|
|
56
|
+
return 'hooks/useFlags/index';
|
|
57
|
+
}
|
|
58
|
+
if (id.includes('useModuleDictionary')) {
|
|
59
|
+
return 'hooks/useModuleDictionary/index';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (id.includes('useLocalStorage')) {
|
|
63
|
+
return 'hooks/useLocalStorage/index';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// utils
|
|
67
|
+
if (id.includes('axios')) {
|
|
68
|
+
return 'external/axios';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (id.includes('snakecase-keys')) {
|
|
72
|
+
return 'external/snakecase-keys';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//utils
|
|
76
|
+
if (id.includes('src/utils')) {
|
|
77
|
+
return 'utils/index';
|
|
78
|
+
}
|
|
79
|
+
//emums
|
|
80
|
+
if (id.includes('src/types')) {
|
|
81
|
+
return 'types/index';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//node_modules no reconocidos
|
|
85
|
+
if (id.includes('node_modules')) {
|
|
86
|
+
return 'node_modules';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log('manualChunks', id, 'api', _api);
|
|
90
|
+
|
|
91
|
+
return 'vendor';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const examined_libs = [];
|
|
95
|
+
|
|
96
|
+
const isExternal = (source: string, importer: string | undefined, isResolved: boolean): boolean => {
|
|
97
|
+
const internal_exact_libs = ['axios', 'snakecase-keys'];
|
|
98
|
+
const external_exact_libs = ['react', 'react-dom', 'react/jsx-runtime', '@m4l/core'];
|
|
99
|
+
const external_parcial_libs = [];
|
|
100
|
+
|
|
101
|
+
if (internal_exact_libs.findIndex(l => source === l) > -1) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const isExt =
|
|
106
|
+
external_exact_libs.findIndex(l => source === l) > -1 ||
|
|
107
|
+
external_parcial_libs.findIndex(pl => source.indexOf(pl) > -1) > -1;
|
|
108
|
+
if (isExt) {
|
|
109
|
+
if (examined_libs.findIndex(l => source === l) < 0) {
|
|
110
|
+
console.log(
|
|
111
|
+
'Source: ',
|
|
112
|
+
source,
|
|
113
|
+
' Importer:',
|
|
114
|
+
' isResolved:',
|
|
115
|
+
isResolved,
|
|
116
|
+
' IsExt:',
|
|
117
|
+
isExt,
|
|
118
|
+
);
|
|
119
|
+
examined_libs.push(source);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return isExt;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default defineConfig({
|
|
127
|
+
server: { https: true, port: 4001 },
|
|
128
|
+
test: {
|
|
129
|
+
globals: true,
|
|
130
|
+
include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
131
|
+
environment: 'jsdom',
|
|
132
|
+
setupFiles: './src/test/setup.ts',
|
|
133
|
+
coverage: {
|
|
134
|
+
all: true,
|
|
135
|
+
include: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
136
|
+
reporter: ['text', 'json', 'html'],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
plugins: [
|
|
141
|
+
react(),
|
|
142
|
+
// terser(),
|
|
143
|
+
mkcert(),
|
|
144
|
+
dts({
|
|
145
|
+
insertTypesEntry: true,
|
|
146
|
+
}),
|
|
147
|
+
],
|
|
148
|
+
// mode: 'production',
|
|
149
|
+
build: {
|
|
150
|
+
//manifest: true,
|
|
151
|
+
target: 'esNext', //Compila en esNext teniendo en cuenta que va a ser leida no por el navedado,sino por otros proyectos
|
|
152
|
+
lib: {
|
|
153
|
+
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
154
|
+
name: 'm4l_core',
|
|
155
|
+
formats: ['es'],
|
|
156
|
+
fileName: () => `index.js`,
|
|
157
|
+
},
|
|
158
|
+
rollupOptions: {
|
|
159
|
+
external: isExternal,
|
|
160
|
+
|
|
161
|
+
input: ['src/index.ts'],
|
|
162
|
+
|
|
163
|
+
output: {
|
|
164
|
+
manualChunks,
|
|
165
|
+
exports: 'auto',
|
|
166
|
+
format: 'esm',
|
|
167
|
+
generatedCode: 'es2015',
|
|
168
|
+
|
|
169
|
+
dir: 'dist',
|
|
170
|
+
globals: {
|
|
171
|
+
react: 'React',
|
|
172
|
+
'react-dom': 'ReactDOM',
|
|
173
|
+
'react/jsx-runtime': 'react/jsx-runtime',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
import "react/jsx-runtime";
|
|
3
|
-
const initialValue = {
|
|
4
|
-
isLocalhost: true,
|
|
5
|
-
host: "",
|
|
6
|
-
domain_token: "",
|
|
7
|
-
host_api_local: "",
|
|
8
|
-
host_api_remote: "",
|
|
9
|
-
host_static_assets: "",
|
|
10
|
-
environment: ""
|
|
11
|
-
};
|
|
12
|
-
const EnvironmentContext = createContext(initialValue);
|
|
13
|
-
export { EnvironmentContext as E };
|
package/dist/HostToolsContext.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
import { v as voidFunction } from "./voidFunction.js";
|
|
3
|
-
import "react/jsx-runtime";
|
|
4
|
-
const initialValue = {
|
|
5
|
-
toast: () => 0,
|
|
6
|
-
startProgress: voidFunction,
|
|
7
|
-
stopProgress: voidFunction,
|
|
8
|
-
events_add_listener: voidFunction,
|
|
9
|
-
events_remove_listener: voidFunction,
|
|
10
|
-
events_emit: voidFunction
|
|
11
|
-
};
|
|
12
|
-
const HostToolsContext = createContext(initialValue);
|
|
13
|
-
export { HostToolsContext as H };
|
package/dist/NetworkContext.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
import "./EnvironmentContext.js";
|
|
3
|
-
import "./HostToolsContext.js";
|
|
4
|
-
import "react/jsx-runtime";
|
|
5
|
-
const initialValue = {
|
|
6
|
-
networkOperation: () => Promise.resolve()
|
|
7
|
-
};
|
|
8
|
-
const NetworkContext = createContext(initialValue);
|
|
9
|
-
export { NetworkContext as N };
|