@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.
Files changed (73) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.cjs +109 -0
  3. package/.prettierignore +2 -0
  4. package/.prettierrc.json +26 -0
  5. package/.vscode/settings.json +50 -0
  6. package/README copy.md +0 -0
  7. package/index.html +13 -0
  8. package/package.json +2 -4
  9. package/package_with_dependicies.json +75 -0
  10. package/src/contexts/EnvironmentContext/index.tsx +37 -0
  11. package/{dist/contexts/EnvironmentContext/types.d.ts → src/contexts/EnvironmentContext/types.ts} +3 -1
  12. package/src/contexts/FlagsContext/index.tsx +50 -0
  13. package/src/contexts/FlagsContext/types.ts +16 -0
  14. package/src/contexts/HostToolsContext/index.tsx +34 -0
  15. package/{dist/contexts/HostToolsContext/types.d.ts → src/contexts/HostToolsContext/types.ts} +3 -1
  16. package/src/contexts/ModuleDictionaryContext/index.tsx +109 -0
  17. package/src/contexts/ModuleDictionaryContext/types.ts +18 -0
  18. package/src/contexts/NetworkContext/index.tsx +44 -0
  19. package/{dist/contexts/NetworkContext/types.d.ts → src/contexts/NetworkContext/types.ts} +6 -2
  20. package/src/contexts/index.ts +5 -0
  21. package/src/hooks/index.ts +7 -0
  22. package/src/hooks/useEnvironment/index.test.tsx +36 -0
  23. package/src/hooks/useEnvironment/index.ts +13 -0
  24. package/src/hooks/useFlags/index.ts +33 -0
  25. package/src/hooks/useHostTools/index.ts +13 -0
  26. package/src/hooks/useLocalStorage/index.ts +23 -0
  27. package/src/hooks/useModuleDictionary/index.ts +11 -0
  28. package/src/hooks/useNetwork/index.ts +13 -0
  29. package/src/index.ts +43 -0
  30. package/src/indexFlags.ts +1 -0
  31. package/src/isolation/App.tsx +24 -0
  32. package/src/main.tsx +10 -0
  33. package/src/prueba.d1.t1 +10 -0
  34. package/src/test/setup.ts +1 -0
  35. package/src/test/utils.tsx +20 -0
  36. package/{dist/types/dictionary.d.ts → src/types/dictionary.ts} +5 -1
  37. package/{dist/types/index.d.ts → src/types/index.ts} +20 -5
  38. package/src/utils/axiosOperation/index.ts +140 -0
  39. package/{dist/utils/axiosOperation/types.d.ts → src/utils/axiosOperation/types.ts} +1 -1
  40. package/src/utils/getLocalStorage.ts +8 -0
  41. package/src/utils/getPropertyByString.ts +10 -0
  42. package/{dist/utils/index.d.ts → src/utils/index.ts} +0 -0
  43. package/src/utils/setLocalStorage.ts +12 -0
  44. package/src/utils/voidFunction.ts +2 -0
  45. package/{dist → src}/vite-env.d.ts +0 -0
  46. package/tsconfig.json +37 -0
  47. package/tsconfig.node.json +10 -0
  48. package/vite.config.ts +178 -0
  49. package/dist/EnvironmentContext.js +0 -13
  50. package/dist/HostToolsContext.js +0 -13
  51. package/dist/NetworkContext.js +0 -9
  52. package/dist/axios.js +0 -1299
  53. package/dist/contexts/EnvironmentContext/index.d.ts +0 -5
  54. package/dist/contexts/HostToolsContext/index.d.ts +0 -6
  55. package/dist/contexts/NetworkContext/index.d.ts +0 -5
  56. package/dist/hooks/useEnvironment/index.d.ts +0 -2
  57. package/dist/hooks/useHostTools/index.d.ts +0 -2
  58. package/dist/hooks/useLocalStorage/index.d.ts +0 -1
  59. package/dist/hooks/useNetwork/index.d.ts +0 -2
  60. package/dist/index.d.ts +0 -8
  61. package/dist/index.js +0 -13
  62. package/dist/snakecase-keys.js +0 -18
  63. package/dist/useEnvironment.js +0 -9
  64. package/dist/useHostTools.js +0 -9
  65. package/dist/useLocalStorage.js +0 -21
  66. package/dist/useNetwork.js +0 -9
  67. package/dist/utils/axiosOperation/index.d.ts +0 -2
  68. package/dist/utils/getLocalStorage.d.ts +0 -1
  69. package/dist/utils/getPropertyByString.d.ts +0 -1
  70. package/dist/utils/setLocalStorage.d.ts +0 -1
  71. package/dist/utils/voidFunction.d.ts +0 -1
  72. package/dist/vendor.js +0 -153
  73. package/dist/voidFunction.js +0 -3
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EnvironmentProviderProps } from './types';
3
- declare const EnvironmentContext: import("react").Context<import("../..").EnvironmentType>;
4
- declare function EnvironmentProvider(props: EnvironmentProviderProps): JSX.Element;
5
- export { EnvironmentProvider, EnvironmentContext };
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { HostToolsType } from '../../types';
3
- import type { HostToolsProviderProps } from './types';
4
- declare const HostToolsContext: import("react").Context<HostToolsType>;
5
- declare function HostToolsProvider(props: HostToolsProviderProps): JSX.Element;
6
- export { HostToolsProvider, HostToolsContext };
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import type { NetworkProviderProps } from './types';
3
- declare const NetworkContext: import("react").Context<import("./types").NetworkType>;
4
- declare function NetworkProvider(props: NetworkProviderProps): JSX.Element;
5
- export { NetworkProvider, NetworkContext };
@@ -1,2 +0,0 @@
1
- export declare const useEnvironment: () => import("../..").EnvironmentType;
2
- export default useEnvironment;
@@ -1,2 +0,0 @@
1
- export declare const useHostTools: () => import("../..").HostToolsType;
2
- export default useHostTools;
@@ -1 +0,0 @@
1
- export declare function useLocalStorage<ValueType>(key: string, initialValue: ValueType): any[];
@@ -1,2 +0,0 @@
1
- export declare const useNetwork: () => import("../../contexts/NetworkContext/types").NetworkType;
2
- export default useNetwork;
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export { useEnvironment } from './hooks/useEnvironment';
2
- export { useHostTools } from './hooks/useHostTools';
3
- export { useLocalStorage } from './hooks/useLocalStorage';
4
- export { useNetwork } from './hooks/useNetwork';
5
- export { EmitEvents } from './types';
6
- export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventFunListener, } from './types';
7
- export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
8
- export * from './utils';
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- export { u as useEnvironment } from "./useEnvironment.js";
2
- export { u as useHostTools } from "./useHostTools.js";
3
- export { u as useLocalStorage } from "./useLocalStorage.js";
4
- export { u as useNetwork } from "./useNetwork.js";
5
- export { E as EmitEvents, a as getLocalStorage, g as getPropertyByString, s as setLocalStorage } from "./vendor.js";
6
- export { v as voidFunction } from "./voidFunction.js";
7
- export { a as axiosOperation } from "./axios.js";
8
- import "react";
9
- import "./EnvironmentContext.js";
10
- import "react/jsx-runtime";
11
- import "./HostToolsContext.js";
12
- import "./NetworkContext.js";
13
- import "./snakecase-keys.js";
@@ -1,18 +0,0 @@
1
- import { m as mapObj, r as require$$1 } from "./vendor.js";
2
- const map = mapObj.exports;
3
- const { snakeCase } = require$$1;
4
- var snakecaseKeys = function(obj, options) {
5
- options = Object.assign({ deep: true, exclude: [], parsingOptions: {} }, options);
6
- return map(obj, function(key, val) {
7
- return [
8
- matches(options.exclude, key) ? key : snakeCase(key, options.parsingOptions),
9
- val
10
- ];
11
- }, options);
12
- };
13
- function matches(patterns, value) {
14
- return patterns.some(function(pattern) {
15
- return typeof pattern === "string" ? pattern === value : pattern.test(value);
16
- });
17
- }
18
- export { snakecaseKeys as s };
@@ -1,9 +0,0 @@
1
- import { useContext } from "react";
2
- import { E as EnvironmentContext } from "./EnvironmentContext.js";
3
- const useEnvironment = () => {
4
- const context = useContext(EnvironmentContext);
5
- if (!context)
6
- throw new Error("useEnvironment context must be use inside EnvironmentContext");
7
- return context;
8
- };
9
- export { useEnvironment as u };
@@ -1,9 +0,0 @@
1
- import { useContext } from "react";
2
- import { H as HostToolsContext } from "./HostToolsContext.js";
3
- const useHostTools = () => {
4
- const context = useContext(HostToolsContext);
5
- if (!context)
6
- throw new Error("useHostTools context must be use inside HostToolsContext");
7
- return context;
8
- };
9
- export { useHostTools as u };
@@ -1,21 +0,0 @@
1
- import { useState } from "react";
2
- function useLocalStorage(key, initialValue) {
3
- const [value, setValue] = useState(() => {
4
- try {
5
- const item = window.localStorage.getItem(key);
6
- return item !== null ? JSON.parse(item) : initialValue;
7
- } catch (e) {
8
- return initialValue;
9
- }
10
- });
11
- const setValueInLocalStorage = (newValue) => {
12
- try {
13
- window.localStorage.setItem(key, JSON.stringify(newValue));
14
- setValue(newValue);
15
- } catch (e) {
16
- console.error(e);
17
- }
18
- };
19
- return [value, setValueInLocalStorage];
20
- }
21
- export { useLocalStorage as u };
@@ -1,9 +0,0 @@
1
- import { useContext } from "react";
2
- import { N as NetworkContext } from "./NetworkContext.js";
3
- const useNetwork = () => {
4
- const context = useContext(NetworkContext);
5
- if (!context)
6
- throw new Error("useNetwork context must be use inside NetworkContext");
7
- return context;
8
- };
9
- export { useNetwork as u };
@@ -1,2 +0,0 @@
1
- import type { EnvironmentType, HostToolsType, NetworkProps } from '../../types';
2
- export declare const axiosOperation: (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
@@ -1 +0,0 @@
1
- export declare function getLocalStorage<ValueType>(key: string, initialValue: ValueType): ValueType;
@@ -1 +0,0 @@
1
- export declare function getPropertyByString(object: Record<string, unknown>, propString: string): any;
@@ -1 +0,0 @@
1
- export declare function setLocalStorage<ValueType>(key: string, value: ValueType): void;
@@ -1 +0,0 @@
1
- export declare function voidFunction(): void;
package/dist/vendor.js DELETED
@@ -1,153 +0,0 @@
1
- import "./axios.js";
2
- import "./useEnvironment.js";
3
- import "./useHostTools.js";
4
- import "./useLocalStorage.js";
5
- import "./useNetwork.js";
6
- import "./voidFunction.js";
7
- var EmitEvents = /* @__PURE__ */ ((EmitEvents2) => {
8
- EmitEvents2["EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED"] = `netsevice_unauthorized`;
9
- EmitEvents2["EMMIT_EVENT_HOST_THEME_CHANGE"] = "host_theme_change";
10
- return EmitEvents2;
11
- })(EmitEvents || {});
12
- function getPropertyByString(object, propString) {
13
- let value = object;
14
- const props = propString.split(".");
15
- for (let index = 0; index < props.length; index += 1) {
16
- if (props[index] === void 0)
17
- break;
18
- value = value[props[index]];
19
- }
20
- return value;
21
- }
22
- function getLocalStorage(key, initialValue) {
23
- try {
24
- const item = window.localStorage.getItem(key);
25
- return item !== null ? JSON.parse(item) : initialValue;
26
- } catch (e) {
27
- return initialValue;
28
- }
29
- }
30
- function setLocalStorage(key, value) {
31
- try {
32
- const item = window.localStorage.getItem(key);
33
- let newValue = item !== null ? JSON.parse(item) : {};
34
- newValue = { ...newValue, ...value };
35
- window.localStorage.setItem(key, JSON.stringify(newValue));
36
- } catch (e) {
37
- console.error(e);
38
- }
39
- }
40
- function getAugmentedNamespace(n) {
41
- if (n.__esModule)
42
- return n;
43
- var a = Object.defineProperty({}, "__esModule", { value: true });
44
- Object.keys(n).forEach(function(k) {
45
- var d = Object.getOwnPropertyDescriptor(n, k);
46
- Object.defineProperty(a, k, d.get ? d : {
47
- enumerable: true,
48
- get: function() {
49
- return n[k];
50
- }
51
- });
52
- });
53
- return a;
54
- }
55
- var mapObj = { exports: {} };
56
- const isObject = (value) => typeof value === "object" && value !== null;
57
- const mapObjectSkip = Symbol("skip");
58
- const isObjectCustom = (value) => isObject(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
59
- const mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
60
- options = {
61
- deep: false,
62
- target: {},
63
- ...options
64
- };
65
- if (isSeen.has(object)) {
66
- return isSeen.get(object);
67
- }
68
- isSeen.set(object, options.target);
69
- const { target } = options;
70
- delete options.target;
71
- const mapArray = (array) => array.map((element) => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element);
72
- if (Array.isArray(object)) {
73
- return mapArray(object);
74
- }
75
- for (const [key, value] of Object.entries(object)) {
76
- const mapResult = mapper(key, value, object);
77
- if (mapResult === mapObjectSkip) {
78
- continue;
79
- }
80
- let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
81
- if (newKey === "__proto__") {
82
- continue;
83
- }
84
- if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
85
- newValue = Array.isArray(newValue) ? mapArray(newValue) : mapObject(newValue, mapper, options, isSeen);
86
- }
87
- target[newKey] = newValue;
88
- }
89
- return target;
90
- };
91
- mapObj.exports = (object, mapper, options) => {
92
- if (!isObject(object)) {
93
- throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
94
- }
95
- return mapObject(object, mapper, options);
96
- };
97
- mapObj.exports.mapObjectSkip = mapObjectSkip;
98
- var __assign = function() {
99
- __assign = Object.assign || function __assign2(t) {
100
- for (var s, i = 1, n = arguments.length; i < n; i++) {
101
- s = arguments[i];
102
- for (var p in s)
103
- if (Object.prototype.hasOwnProperty.call(s, p))
104
- t[p] = s[p];
105
- }
106
- return t;
107
- };
108
- return __assign.apply(this, arguments);
109
- };
110
- function lowerCase(str) {
111
- return str.toLowerCase();
112
- }
113
- var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
114
- var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
115
- function noCase(input, options) {
116
- if (options === void 0) {
117
- options = {};
118
- }
119
- var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
120
- var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
121
- var start = 0;
122
- var end = result.length;
123
- while (result.charAt(start) === "\0")
124
- start++;
125
- while (result.charAt(end - 1) === "\0")
126
- end--;
127
- return result.slice(start, end).split("\0").map(transform).join(delimiter);
128
- }
129
- function replace(input, re, value) {
130
- if (re instanceof RegExp)
131
- return input.replace(re, value);
132
- return re.reduce(function(input2, re2) {
133
- return input2.replace(re2, value);
134
- }, input);
135
- }
136
- function dotCase(input, options) {
137
- if (options === void 0) {
138
- options = {};
139
- }
140
- return noCase(input, __assign({ delimiter: "." }, options));
141
- }
142
- function snakeCase(input, options) {
143
- if (options === void 0) {
144
- options = {};
145
- }
146
- return dotCase(input, __assign({ delimiter: "_" }, options));
147
- }
148
- const dist_es2015 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149
- __proto__: null,
150
- snakeCase
151
- }, Symbol.toStringTag, { value: "Module" }));
152
- const require$$1 = /* @__PURE__ */ getAugmentedNamespace(dist_es2015);
153
- export { EmitEvents as E, getLocalStorage as a, getPropertyByString as g, mapObj as m, require$$1 as r, setLocalStorage as s };
@@ -1,3 +0,0 @@
1
- function voidFunction() {
2
- }
3
- export { voidFunction as v };