@fctc/interface-logic 5.0.9 → 5.1.2

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 (49) hide show
  1. package/dist/chunk-4NLKHYBY.js +131 -0
  2. package/dist/chunk-6LSKTACC.js +687 -0
  3. package/dist/chunk-B432GFRR.mjs +606 -0
  4. package/dist/chunk-BPJZ3QRN.mjs +3025 -0
  5. package/dist/chunk-BZYCE2VA.js +301 -0
  6. package/dist/chunk-FDVY2DBI.mjs +127 -0
  7. package/dist/chunk-GGNOJ77I.js +2 -0
  8. package/dist/chunk-H2VMULTO.mjs +6161 -0
  9. package/dist/chunk-IUYYGSEL.js +321 -0
  10. package/dist/chunk-IVXH2HOR.js +6321 -0
  11. package/dist/chunk-JDXUTKMX.js +3065 -0
  12. package/dist/chunk-JNLBHOL4.mjs +284 -0
  13. package/dist/chunk-MJEZ4MMQ.mjs +315 -0
  14. package/dist/chunk-WAXGOBY2.mjs +1 -0
  15. package/dist/chunk-XA7EW3ZX.mjs +114 -0
  16. package/dist/chunk-YKB32DSB.js +116 -0
  17. package/dist/configs.js +7 -2577
  18. package/dist/configs.mjs +3 -2545
  19. package/dist/constants.d.mts +4 -16
  20. package/dist/constants.d.ts +4 -16
  21. package/dist/constants.js +65 -355
  22. package/dist/constants.mjs +1 -318
  23. package/dist/environment.js +16 -2704
  24. package/dist/environment.mjs +4 -2670
  25. package/dist/hooks.d.mts +19 -89
  26. package/dist/hooks.d.ts +19 -89
  27. package/dist/hooks.js +557 -10358
  28. package/dist/hooks.mjs +6 -10177
  29. package/dist/index.d.mts +2 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.js +1179 -12592
  32. package/dist/index.mjs +8 -12256
  33. package/dist/models.js +7 -143
  34. package/dist/models.mjs +2 -120
  35. package/dist/provider.d.mts +2 -14
  36. package/dist/provider.d.ts +2 -14
  37. package/dist/provider.js +37 -10907
  38. package/dist/provider.mjs +6 -10875
  39. package/dist/services.d.mts +18 -103
  40. package/dist/services.d.ts +18 -103
  41. package/dist/services.js +40 -8121
  42. package/dist/services.mjs +6 -8089
  43. package/dist/store.js +320 -817
  44. package/dist/store.mjs +1 -717
  45. package/dist/types.js +3 -17
  46. package/dist/types.mjs +1 -0
  47. package/dist/utils.js +134 -3094
  48. package/dist/utils.mjs +2 -3030
  49. package/package.json +93 -92
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var chunkIUYYGSEL_js = require('./chunk-IUYYGSEL.js');
4
+ var chunkJDXUTKMX_js = require('./chunk-JDXUTKMX.js');
5
+
6
+ // src/environment/EnvStore.ts
7
+ var EventEmitter = class {
8
+ listeners = {};
9
+ on(event, callback) {
10
+ if (!this.listeners[event]) {
11
+ this.listeners[event] = [];
12
+ }
13
+ this.listeners[event].push(callback);
14
+ }
15
+ emit(event, data) {
16
+ if (this.listeners[event]) {
17
+ this.listeners[event].forEach((callback) => callback(data));
18
+ }
19
+ }
20
+ };
21
+ var EnvStore = class {
22
+ state;
23
+ emitter;
24
+ localStorageUtil;
25
+ sessionStorageUtil;
26
+ constructor(localStorageUtil = chunkJDXUTKMX_js.localStorageUtils(), sessionStorageUtil = chunkJDXUTKMX_js.sessionStorageUtils) {
27
+ this.state = {
28
+ baseUrl: "",
29
+ requests: null,
30
+ companies: [],
31
+ user: {},
32
+ config: null,
33
+ envFile: null,
34
+ defaultCompany: {
35
+ id: null,
36
+ logo: "",
37
+ secondary_color: "",
38
+ primary_color: ""
39
+ },
40
+ context: {
41
+ uid: null,
42
+ allowed_company_ids: [],
43
+ lang: "vi_VN",
44
+ tz: "Asia/Saigon"
45
+ },
46
+ localStorageUtils: localStorageUtil,
47
+ sessionStorageUtils: sessionStorageUtil
48
+ };
49
+ this.emitter = new EventEmitter();
50
+ this.localStorageUtil = localStorageUtil;
51
+ this.sessionStorageUtil = sessionStorageUtil;
52
+ }
53
+ getEnv() {
54
+ return { ...this.state };
55
+ }
56
+ onUpdate(callback) {
57
+ this.emitter.on("update", callback);
58
+ }
59
+ setupEnv(envConfig) {
60
+ this.state = {
61
+ ...this.state,
62
+ ...envConfig,
63
+ localStorageUtils: this.localStorageUtil,
64
+ sessionStorageUtils: this.sessionStorageUtil
65
+ };
66
+ this.state.requests = chunkIUYYGSEL_js.axiosClient.init(this.state);
67
+ this.emitter.emit("update", this.getEnv());
68
+ return this.getEnv();
69
+ }
70
+ setUid(uid) {
71
+ this.state = {
72
+ ...this.state,
73
+ context: { ...this.state.context, uid }
74
+ };
75
+ this.emitter.emit("update", this.getEnv());
76
+ }
77
+ setLang(lang) {
78
+ this.state = {
79
+ ...this.state,
80
+ context: { ...this.state.context, lang }
81
+ };
82
+ this.emitter.emit("update", this.getEnv());
83
+ }
84
+ setAllowCompanies(allowed_company_ids) {
85
+ this.state = {
86
+ ...this.state,
87
+ context: { ...this.state.context, allowed_company_ids }
88
+ };
89
+ this.emitter.emit("update", this.getEnv());
90
+ }
91
+ setCompanies(companies) {
92
+ this.state = { ...this.state, companies };
93
+ this.emitter.emit("update", this.getEnv());
94
+ }
95
+ setDefaultCompany(defaultCompany) {
96
+ this.state = { ...this.state, defaultCompany };
97
+ this.emitter.emit("update", this.getEnv());
98
+ }
99
+ setUserInfo(user) {
100
+ this.state = { ...this.state, user };
101
+ this.emitter.emit("update", this.getEnv());
102
+ }
103
+ setConfig(config) {
104
+ this.state = { ...this.state, config };
105
+ this.emitter.emit("update", this.getEnv());
106
+ }
107
+ setEnvFile(envFile) {
108
+ this.state = { ...this.state, envFile };
109
+ this.emitter.emit("update", this.getEnv());
110
+ }
111
+ };
112
+ var env = null;
113
+ function initEnv({
114
+ localStorageUtils: localStorageUtil = chunkJDXUTKMX_js.localStorageUtils(),
115
+ sessionStorageUtils: sessionStorageUtil = chunkJDXUTKMX_js.sessionStorageUtils
116
+ }) {
117
+ if (!env) {
118
+ env = new EnvStore(localStorageUtil, sessionStorageUtil);
119
+ }
120
+ return env;
121
+ }
122
+ function getEnv() {
123
+ if (!env) {
124
+ env = initEnv({});
125
+ }
126
+ return env?.getEnv();
127
+ }
128
+
129
+ exports.EnvStore = EnvStore;
130
+ exports.getEnv = getEnv;
131
+ exports.initEnv = initEnv;