slicejs-web-framework 4.0.0 β†’ 4.0.1

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 (70) hide show
  1. package/.opencode/opencode.json +14 -14
  2. package/LICENSE +21 -21
  3. package/README.md +97 -97
  4. package/Slice/Components/Structural/ContextManager/ContextManager.js +422 -422
  5. package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +470 -470
  6. package/Slice/Components/Structural/Controller/Controller.js +1406 -1406
  7. package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -52
  8. package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
  9. package/Slice/Components/Structural/Debugger/Debugger.js +1505 -1505
  10. package/Slice/Components/Structural/EventManager/EventManager.js +651 -651
  11. package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +985 -985
  12. package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -296
  13. package/Slice/Components/Structural/Logger/Log.js +10 -10
  14. package/Slice/Components/Structural/Logger/LogViewer/LogViewer.js +662 -662
  15. package/Slice/Components/Structural/Logger/Logger.js +225 -225
  16. package/Slice/Components/Structural/Router/Router.js +793 -793
  17. package/Slice/Components/Structural/StylesManager/StylesManager.js +82 -82
  18. package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +162 -162
  19. package/Slice/Slice.js +686 -697
  20. package/Slice/tests/build-bundled-component-without-category.test.js +103 -103
  21. package/Slice/tests/build-js-only-visual-components.test.js +144 -144
  22. package/Slice/tests/build-singleton.test.js +244 -244
  23. package/Slice/tests/bundle-v2-runtime-contract.test.js +738 -738
  24. package/Slice/tests/context-patch-use.test.js +95 -95
  25. package/Slice/tests/destroy-cascade.test.js +215 -215
  26. package/Slice/tests/event-emitters.test.js +79 -79
  27. package/Slice/tests/event-registry.test.js +141 -141
  28. package/Slice/tests/fixtures/real-runtime-loader.mjs +21 -21
  29. package/Slice/tests/leak-orphans.test.js +131 -131
  30. package/Slice/tests/props-allowed-values-validation.test.js +119 -119
  31. package/Slice/tests/public-env-runtime-accessors.test.js +44 -44
  32. package/Slice/tests/public-env-typed-accessors.test.js +66 -66
  33. package/Slice/tests/router-loading-finally.test.js +68 -68
  34. package/api/framework/devDepsOptimizer.js +335 -335
  35. package/api/framework/express.js +3 -3
  36. package/api/framework/precompressedStatic.js +93 -93
  37. package/api/framework/publicEnvResolver.js +123 -123
  38. package/api/framework/securityMiddleware.js +197 -197
  39. package/api/framework/server.js +411 -411
  40. package/api/index.js +7 -7
  41. package/api/tests/dev-deps-optimizer.test.js +137 -137
  42. package/api/tests/dev-server-external.test.js +56 -56
  43. package/api/tests/precompressed-static.test.js +119 -119
  44. package/api/tests/public-env-resolver.test.js +193 -193
  45. package/package.json +49 -49
  46. package/sliceConfig.schema.json +122 -122
  47. package/src/App/index.html +69 -69
  48. package/src/App/index.js +20 -20
  49. package/src/App/style.css +11 -11
  50. package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -9
  51. package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -8
  52. package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -12
  53. package/src/Components/AppComponents/AppShell/AppShell.css +10 -10
  54. package/src/Components/AppComponents/AppShell/AppShell.html +4 -4
  55. package/src/Components/AppComponents/AppShell/AppShell.js +36 -36
  56. package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -20
  57. package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -10
  58. package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -19
  59. package/src/Components/components.js +8 -8
  60. package/src/public/Styles/sliceStyles.css +34 -34
  61. package/src/public/Themes/Dark.css +42 -42
  62. package/src/public/Themes/Light.css +31 -31
  63. package/src/public/Themes/Slice.css +47 -47
  64. package/src/public/manifest.json +15 -15
  65. package/src/public/robots.txt +4 -4
  66. package/src/public/sitemap.xml +8 -8
  67. package/src/routes.js +9 -9
  68. package/src/sliceConfig.json +72 -72
  69. package/tests/router-emit-ordering.test.js +63 -63
  70. package/types/index.d.ts +219 -219
@@ -1,225 +1,225 @@
1
- import Log from './Log.js';
2
-
3
- const logTypes = {
4
- ERROR: 'error',
5
- WARN: 'warn',
6
- INFO: 'info',
7
- DEBUG: 'debug',
8
- };
9
-
10
- export default class Logger {
11
- constructor() {
12
- this.logs = [];
13
- this._logListeners = new Set();
14
- this.logEnabled = slice.loggerConfig.enabled;
15
- this.showLogsConfig = slice.loggerConfig.showLogs;
16
-
17
- this.showLog = function showLog(log) {
18
- if (!this.showLogsConfig) return;
19
-
20
- const logType = log.logType;
21
-
22
- Object.keys(this.showLogsConfig).forEach((logConfig) => {
23
- if (this.showLogsConfig[logConfig][logType] === true) {
24
- switch (logConfig) {
25
- case 'console':
26
- switch (logType) {
27
- case logTypes.ERROR:
28
- console.error(
29
- `\x1b[31mERROR\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
30
- log.error
31
- );
32
- break;
33
- case logTypes.WARN:
34
- if (log.error) {
35
- console.warn(
36
- `\x1b[33m⚠ WARN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
37
- log.error
38
- );
39
- } else {
40
- console.warn(
41
- `\x1b[33m⚠ WARN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
42
- );
43
- }
44
- break;
45
- case logTypes.INFO:
46
- if (log.error) {
47
- console.log(
48
- `\x1b[32mβœ” INFO\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
49
- log.error
50
- );
51
- } else {
52
- console.log(
53
- `\x1b[32mβœ” INFO\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
54
- );
55
- }
56
- break;
57
- case logTypes.DEBUG:
58
- if (log.error) {
59
- console.debug(
60
- `\x1b[36mπŸ” DEBUG\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
61
- log.error
62
- );
63
- } else {
64
- console.debug(
65
- `\x1b[36mπŸ” DEBUG\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
66
- );
67
- }
68
- break;
69
- default:
70
- console.log(
71
- `\x1b[37mUNKNOWN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
72
- );
73
- }
74
- break;
75
- }
76
- }
77
- });
78
- };
79
- }
80
-
81
- createLog(logType, componentSliceId, message, error = null) {
82
- if (!this.logEnabled) return;
83
- let componentName;
84
-
85
- try {
86
- componentName = slice.controller.activeComponents.get(componentSliceId).constructor.name;
87
- } catch (_err) {
88
- componentName = componentSliceId;
89
- }
90
-
91
- let componentCategory = slice.controller.getComponentCategory(componentName);
92
- if (componentSliceId === 'Slice' || componentSliceId === 'ThemeManager') componentCategory = 'Structural';
93
- const log = new Log(logType, componentCategory, componentSliceId, message, error);
94
- this.logs.push(log);
95
- this.showLog(log);
96
- for (const listener of this._logListeners) {
97
- try { listener(log); } catch (_) { }
98
- }
99
- }
100
-
101
- /**
102
- * Log an error message.
103
- * @param {string} componentSliceId
104
- * @param {string} message
105
- * @param {any} [error]
106
- * @returns {void}
107
- */
108
- error(componentSliceId, message, error) {
109
- this.createLog(logTypes.ERROR, componentSliceId, message, error);
110
- }
111
-
112
- /**
113
- * Log a warning message.
114
- * @param {string} componentSliceId
115
- * @param {string} message
116
- * @param {any} [error]
117
- * @returns {void}
118
- */
119
- warn(componentSliceId, message, error) {
120
- this.createLog(logTypes.WARN, componentSliceId, message, error);
121
- }
122
-
123
- /**
124
- * Log an info message.
125
- * @param {string} componentSliceId
126
- * @param {string} message
127
- * @param {any} [error]
128
- * @returns {void}
129
- */
130
- info(componentSliceId, message, error) {
131
- this.createLog(logTypes.INFO, componentSliceId, message, error);
132
- }
133
-
134
- /**
135
- * Log a debug message.
136
- * @param {string} componentSliceId
137
- * @param {string} message
138
- * @param {any} [error]
139
- * @returns {void}
140
- */
141
- debug(componentSliceId, message, error) {
142
- this.createLog(logTypes.DEBUG, componentSliceId, message, error);
143
- }
144
-
145
- // ── Retrocompatibilidad: mΓ©todos antiguos redirigen a los nuevos ──
146
-
147
- /** @deprecated Use .error() instead */
148
- logError(componentSliceId, message, error) {
149
- this.error(componentSliceId, message, error);
150
- }
151
-
152
- /** @deprecated Use .warn() instead */
153
- logWarning(componentSliceId, message, error) {
154
- this.warn(componentSliceId, message, error);
155
- }
156
-
157
- /** @deprecated Use .info() instead */
158
- logInfo(componentSliceId, message, error) {
159
- this.info(componentSliceId, message, error);
160
- }
161
-
162
- /**
163
- * Subscribe to new log entries in real time.
164
- * @param {Function} callback β€” receives the Log instance
165
- * @returns {Function} the same callback (for passing to offLog)
166
- */
167
- onLog(callback) {
168
- if (typeof callback === 'function') {
169
- this._logListeners.add(callback);
170
- }
171
- return callback;
172
- }
173
-
174
- /**
175
- * Unsubscribe a previously registered listener.
176
- * @param {Function} callback
177
- * @returns {void}
178
- */
179
- offLog(callback) {
180
- this._logListeners.delete(callback);
181
- }
182
-
183
- /**
184
- * Get all logs.
185
- * @returns {Array}
186
- */
187
- getLogs() {
188
- return this.logs;
189
- }
190
-
191
- /**
192
- * Clear all logs.
193
- * @returns {void}
194
- */
195
- clearLogs() {
196
- this.logs = [];
197
- }
198
-
199
- /**
200
- * Filter logs by type.
201
- * @param {string} type
202
- * @returns {Array}
203
- */
204
- getLogsByLogType(type) {
205
- return this.logs.filter((log) => log.logType === type);
206
- }
207
-
208
- /**
209
- * Filter logs by component category.
210
- * @param {string} componentCategory
211
- * @returns {Array}
212
- */
213
- getLogsByComponentCategory(componentCategory) {
214
- return this.logs.filter((log) => log.componentCategory === componentCategory);
215
- }
216
-
217
- /**
218
- * Filter logs by component sliceId.
219
- * @param {string} componentSliceId
220
- * @returns {Array}
221
- */
222
- getLogsByComponent(componentSliceId) {
223
- return this.logs.filter((log) => log.componentSliceId === componentSliceId);
224
- }
225
- }
1
+ import Log from './Log.js';
2
+
3
+ const logTypes = {
4
+ ERROR: 'error',
5
+ WARN: 'warn',
6
+ INFO: 'info',
7
+ DEBUG: 'debug',
8
+ };
9
+
10
+ export default class Logger {
11
+ constructor() {
12
+ this.logs = [];
13
+ this._logListeners = new Set();
14
+ this.logEnabled = slice.loggerConfig.enabled;
15
+ this.showLogsConfig = slice.loggerConfig.showLogs;
16
+
17
+ this.showLog = function showLog(log) {
18
+ if (!this.showLogsConfig) return;
19
+
20
+ const logType = log.logType;
21
+
22
+ Object.keys(this.showLogsConfig).forEach((logConfig) => {
23
+ if (this.showLogsConfig[logConfig][logType] === true) {
24
+ switch (logConfig) {
25
+ case 'console':
26
+ switch (logType) {
27
+ case logTypes.ERROR:
28
+ console.error(
29
+ `\x1b[31mERROR\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
30
+ log.error
31
+ );
32
+ break;
33
+ case logTypes.WARN:
34
+ if (log.error) {
35
+ console.warn(
36
+ `\x1b[33m⚠ WARN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
37
+ log.error
38
+ );
39
+ } else {
40
+ console.warn(
41
+ `\x1b[33m⚠ WARN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
42
+ );
43
+ }
44
+ break;
45
+ case logTypes.INFO:
46
+ if (log.error) {
47
+ console.log(
48
+ `\x1b[32mβœ” INFO\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
49
+ log.error
50
+ );
51
+ } else {
52
+ console.log(
53
+ `\x1b[32mβœ” INFO\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
54
+ );
55
+ }
56
+ break;
57
+ case logTypes.DEBUG:
58
+ if (log.error) {
59
+ console.debug(
60
+ `\x1b[36mπŸ” DEBUG\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`,
61
+ log.error
62
+ );
63
+ } else {
64
+ console.debug(
65
+ `\x1b[36mπŸ” DEBUG\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
66
+ );
67
+ }
68
+ break;
69
+ default:
70
+ console.log(
71
+ `\x1b[37mUNKNOWN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`
72
+ );
73
+ }
74
+ break;
75
+ }
76
+ }
77
+ });
78
+ };
79
+ }
80
+
81
+ createLog(logType, componentSliceId, message, error = null) {
82
+ if (!this.logEnabled) return;
83
+ let componentName;
84
+
85
+ try {
86
+ componentName = slice.controller.activeComponents.get(componentSliceId).constructor.name;
87
+ } catch (_err) {
88
+ componentName = componentSliceId;
89
+ }
90
+
91
+ let componentCategory = slice.controller.getComponentCategory(componentName);
92
+ if (componentSliceId === 'Slice' || componentSliceId === 'ThemeManager') componentCategory = 'Structural';
93
+ const log = new Log(logType, componentCategory, componentSliceId, message, error);
94
+ this.logs.push(log);
95
+ this.showLog(log);
96
+ for (const listener of this._logListeners) {
97
+ try { listener(log); } catch (_) { }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Log an error message.
103
+ * @param {string} componentSliceId
104
+ * @param {string} message
105
+ * @param {any} [error]
106
+ * @returns {void}
107
+ */
108
+ error(componentSliceId, message, error) {
109
+ this.createLog(logTypes.ERROR, componentSliceId, message, error);
110
+ }
111
+
112
+ /**
113
+ * Log a warning message.
114
+ * @param {string} componentSliceId
115
+ * @param {string} message
116
+ * @param {any} [error]
117
+ * @returns {void}
118
+ */
119
+ warn(componentSliceId, message, error) {
120
+ this.createLog(logTypes.WARN, componentSliceId, message, error);
121
+ }
122
+
123
+ /**
124
+ * Log an info message.
125
+ * @param {string} componentSliceId
126
+ * @param {string} message
127
+ * @param {any} [error]
128
+ * @returns {void}
129
+ */
130
+ info(componentSliceId, message, error) {
131
+ this.createLog(logTypes.INFO, componentSliceId, message, error);
132
+ }
133
+
134
+ /**
135
+ * Log a debug message.
136
+ * @param {string} componentSliceId
137
+ * @param {string} message
138
+ * @param {any} [error]
139
+ * @returns {void}
140
+ */
141
+ debug(componentSliceId, message, error) {
142
+ this.createLog(logTypes.DEBUG, componentSliceId, message, error);
143
+ }
144
+
145
+ // ── Retrocompatibilidad: mΓ©todos antiguos redirigen a los nuevos ──
146
+
147
+ /** @deprecated Use .error() instead */
148
+ logError(componentSliceId, message, error) {
149
+ this.error(componentSliceId, message, error);
150
+ }
151
+
152
+ /** @deprecated Use .warn() instead */
153
+ logWarning(componentSliceId, message, error) {
154
+ this.warn(componentSliceId, message, error);
155
+ }
156
+
157
+ /** @deprecated Use .info() instead */
158
+ logInfo(componentSliceId, message, error) {
159
+ this.info(componentSliceId, message, error);
160
+ }
161
+
162
+ /**
163
+ * Subscribe to new log entries in real time.
164
+ * @param {Function} callback β€” receives the Log instance
165
+ * @returns {Function} the same callback (for passing to offLog)
166
+ */
167
+ onLog(callback) {
168
+ if (typeof callback === 'function') {
169
+ this._logListeners.add(callback);
170
+ }
171
+ return callback;
172
+ }
173
+
174
+ /**
175
+ * Unsubscribe a previously registered listener.
176
+ * @param {Function} callback
177
+ * @returns {void}
178
+ */
179
+ offLog(callback) {
180
+ this._logListeners.delete(callback);
181
+ }
182
+
183
+ /**
184
+ * Get all logs.
185
+ * @returns {Array}
186
+ */
187
+ getLogs() {
188
+ return this.logs;
189
+ }
190
+
191
+ /**
192
+ * Clear all logs.
193
+ * @returns {void}
194
+ */
195
+ clearLogs() {
196
+ this.logs = [];
197
+ }
198
+
199
+ /**
200
+ * Filter logs by type.
201
+ * @param {string} type
202
+ * @returns {Array}
203
+ */
204
+ getLogsByLogType(type) {
205
+ return this.logs.filter((log) => log.logType === type);
206
+ }
207
+
208
+ /**
209
+ * Filter logs by component category.
210
+ * @param {string} componentCategory
211
+ * @returns {Array}
212
+ */
213
+ getLogsByComponentCategory(componentCategory) {
214
+ return this.logs.filter((log) => log.componentCategory === componentCategory);
215
+ }
216
+
217
+ /**
218
+ * Filter logs by component sliceId.
219
+ * @param {string} componentSliceId
220
+ * @returns {Array}
221
+ */
222
+ getLogsByComponent(componentSliceId) {
223
+ return this.logs.filter((log) => log.componentSliceId === componentSliceId);
224
+ }
225
+ }