slicejs-web-framework 3.1.3 → 3.1.4

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/Slice/Slice.js CHANGED
@@ -105,18 +105,23 @@ export default class Slice {
105
105
  return null;
106
106
  }
107
107
 
108
- if (!this.controller.componentCategories.has(componentName)) {
109
- this.logger.logError('Slice', null, `Component ${componentName} not found in components.js file`);
110
- return null;
111
- }
112
-
113
108
  // 📦 Try to load from bundles first
114
109
  const bundleName = this.controller.getBundleForComponent(componentName);
115
110
  if (bundleName && !this.controller.loadedBundles.has(bundleName)) {
116
111
  await this.controller.loadBundle(bundleName);
117
112
  }
118
113
 
114
+ // After bundle loading attempt, allow build when class is already available
115
+ // even if components map has no category entry (stale/components.js mismatch).
116
+ if (!this.controller.componentCategories.has(componentName) && !this.controller.classes.has(componentName)) {
117
+ this.logger.logError('Slice', null, `Component ${componentName} not found in components.js file`);
118
+ return null;
119
+ }
120
+
119
121
  let componentCategory = this.controller.componentCategories.get(componentName);
122
+ if (!componentCategory && this.controller.classes.has(componentName)) {
123
+ componentCategory = 'AppComponents';
124
+ }
120
125
 
121
126
  // 📦 Check if component is already available from loaded bundles
122
127
  const isFromBundle = this.controller.isComponentFromBundle(componentName);
@@ -130,7 +135,7 @@ export default class Slice {
130
135
  return null;
131
136
  }
132
137
 
133
- let isVisual = slice.paths.components[componentCategory].type === 'Visual';
138
+ let isVisual = slice.paths.components[componentCategory]?.type === 'Visual';
134
139
  let modulePath = `${slice.paths.components[componentCategory].path}/${componentName}/${componentName}.js`;
135
140
  const isJsOnlyVisualComponent = isVisual && (componentName === 'MultiRoute' || componentName === 'Route');
136
141
 
@@ -0,0 +1,103 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+
4
+ globalThis.alert = () => {};
5
+
6
+ const { default: Slice } = await import('../Slice.js');
7
+
8
+ class FakeController {
9
+ constructor() {
10
+ this.componentCategories = new Map();
11
+ this.templates = new Map();
12
+ this.classes = new Map();
13
+ this.requestedStyles = new Set();
14
+ this.loadedBundles = new Set();
15
+ this.activeComponents = new Map();
16
+ this.bundleLoads = 0;
17
+ }
18
+
19
+ getBundleForComponent(componentName) {
20
+ return componentName === 'DocumentationPage' ? 'multiroute-DocumentationPage--p1' : null;
21
+ }
22
+
23
+ async loadBundle(bundleName) {
24
+ this.bundleLoads += 1;
25
+ this.loadedBundles.add(bundleName);
26
+ this.classes.set(
27
+ 'DocumentationPage',
28
+ class DocumentationPage {
29
+ constructor(props) {
30
+ this.props = props;
31
+ this.sliceId = 'DocumentationPage';
32
+ }
33
+ async init() {}
34
+ }
35
+ );
36
+ }
37
+
38
+ isComponentFromBundle(componentName) {
39
+ return componentName === 'DocumentationPage' && this.loadedBundles.has('multiroute-DocumentationPage--p1');
40
+ }
41
+
42
+ verifyComponentIds() {
43
+ return true;
44
+ }
45
+
46
+ registerComponent() {}
47
+
48
+ registerComponentsRecursively() {}
49
+ }
50
+
51
+ class FakeStylesManager {
52
+ registerComponentStyles() {}
53
+ }
54
+
55
+ function createSlice() {
56
+ const instance = new Slice(
57
+ {
58
+ paths: {
59
+ components: {
60
+ AppComponents: {
61
+ path: '/Components/AppComponents',
62
+ type: 'Visual'
63
+ }
64
+ }
65
+ },
66
+ themeManager: {},
67
+ stylesManager: {},
68
+ logger: {},
69
+ debugger: { enabled: false },
70
+ loading: {},
71
+ events: {}
72
+ },
73
+ {
74
+ Controller: FakeController,
75
+ StylesManager: FakeStylesManager
76
+ }
77
+ );
78
+
79
+ instance.logger = {
80
+ logError() {},
81
+ logWarning() {},
82
+ logInfo() {}
83
+ };
84
+
85
+ return instance;
86
+ }
87
+
88
+ test('build succeeds for bundled component even when componentCategories is missing entry', async () => {
89
+ const originalSlice = globalThis.slice;
90
+
91
+ try {
92
+ const sliceInstance = createSlice();
93
+ globalThis.slice = sliceInstance;
94
+
95
+ const component = await sliceInstance.build('DocumentationPage', { from: 'route' });
96
+
97
+ assert.ok(component);
98
+ assert.equal(component.sliceId, 'DocumentationPage');
99
+ assert.equal(sliceInstance.controller.bundleLoads, 1);
100
+ } finally {
101
+ globalThis.slice = originalSlice;
102
+ }
103
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-web-framework",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=20"