slicejs-web-framework 3.2.2 → 3.3.0
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/.opencode/opencode.json +14 -0
- package/README.md +57 -134
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +233 -110
- package/Slice/Components/Structural/Controller/Controller.js +9 -0
- package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -0
- package/Slice/Components/Structural/Debugger/Debugger.js +392 -442
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +264 -149
- package/Slice/Components/Structural/Router/Router.js +45 -14
- package/Slice/tests/props-allowed-values-validation.test.js +119 -0
- package/package.json +11 -9
- package/src/App/index.html +2 -8
- package/src/App/index.js +18 -21
- package/src/App/style.css +8 -37
- package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -0
- package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -0
- package/src/Components/AppComponents/AppShell/AppShell.css +10 -0
- package/src/Components/AppComponents/AppShell/AppShell.html +4 -0
- package/src/Components/AppComponents/AppShell/AppShell.js +36 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -0
- package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -0
- package/src/Components/Visual/MultiRoute/MultiRoute.js +13 -6
- package/src/Components/components.js +4 -16
- package/src/routes.js +6 -12
- package/src/sliceConfig.json +2 -1
- package/Slice/Components/Structural/Debugger/Debugger.css +0 -620
- package/src/Components/AppComponents/HomePage/HomePage.css +0 -201
- package/src/Components/AppComponents/HomePage/HomePage.html +0 -37
- package/src/Components/AppComponents/HomePage/HomePage.js +0 -210
- package/src/Components/AppComponents/Playground/Playground.css +0 -12
- package/src/Components/AppComponents/Playground/Playground.html +0 -0
- package/src/Components/AppComponents/Playground/Playground.js +0 -111
- package/src/images/Slice.js-logo.png +0 -0
- package/src/images/im2/Slice.js-logo.png +0 -0
- package/src/testing.js +0 -888
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj || {}, key);
|
|
2
|
+
|
|
3
|
+
const formatValueForLog = (value) => {
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
return `'${value}'`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (value === undefined) return 'undefined';
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return JSON.stringify(value);
|
|
12
|
+
} catch (_) {
|
|
13
|
+
return String(value);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const collectInvalidAllowedValueProps = (staticProps, providedProps) => {
|
|
18
|
+
const invalid = [];
|
|
19
|
+
const safeProvidedProps = providedProps || {};
|
|
20
|
+
|
|
21
|
+
Object.entries(staticProps || {}).forEach(([propName, config]) => {
|
|
22
|
+
const allowedValues = config?.allowedValues;
|
|
23
|
+
if (!Array.isArray(allowedValues) || allowedValues.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!hasOwn(safeProvidedProps, propName)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const value = safeProvidedProps[propName];
|
|
32
|
+
const isAllowed = allowedValues.some((allowedValue) => allowedValue === value);
|
|
33
|
+
if (!isAllowed) {
|
|
34
|
+
invalid.push({
|
|
35
|
+
propName,
|
|
36
|
+
value,
|
|
37
|
+
allowedValues
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return invalid;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const formatAllowedValuesForLog = (allowedValues) => {
|
|
46
|
+
if (!Array.isArray(allowedValues) || allowedValues.length === 0) {
|
|
47
|
+
return '[]';
|
|
48
|
+
}
|
|
49
|
+
return `[${allowedValues.map((value) => formatValueForLog(value)).join(', ')}]`;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { collectInvalidAllowedValueProps, formatAllowedValuesForLog };
|