slicejs-web-framework 2.2.11 → 2.2.13

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.
@@ -50,7 +50,16 @@ export default class Controller {
50
50
  }
51
51
 
52
52
  try {
53
- const bundleInfo = this.bundleConfig?.bundles?.routes?.[bundleName];
53
+ let bundleInfo = this.bundleConfig?.bundles?.routes?.[bundleName];
54
+
55
+ if (!bundleInfo && this.bundleConfig?.bundles?.routes) {
56
+ const normalizedName = bundleName?.toLowerCase();
57
+ const matchedKey = Object.keys(this.bundleConfig.bundles.routes)
58
+ .find(key => key.toLowerCase() === normalizedName);
59
+ if (matchedKey) {
60
+ bundleInfo = this.bundleConfig.bundles.routes[matchedKey];
61
+ }
62
+ }
54
63
 
55
64
  if (!bundleInfo) {
56
65
  console.warn(`Bundle ${bundleName} not found in configuration`);
@@ -240,9 +249,19 @@ export default class Controller {
240
249
  const processedDeps = new Set();
241
250
  for (const [componentName, componentData] of Object.entries(components)) {
242
251
  if (componentData.externalDependencies) {
243
- for (const [depName, depContent] of Object.entries(componentData.externalDependencies)) {
244
- if (!processedDeps.has(depName)) {
252
+ for (const [depName, depEntry] of Object.entries(componentData.externalDependencies)) {
253
+ const depKey = depName || '';
254
+ if (!processedDeps.has(depKey)) {
245
255
  try {
256
+ const depContent = typeof depEntry === 'string' ? depEntry : depEntry.content;
257
+ const bindings = typeof depEntry === 'string' ? [] : (depEntry.bindings || []);
258
+
259
+ const fileBaseName = depKey
260
+ ? depKey.split('/').pop().replace(/\.[^.]+$/, '')
261
+ : '';
262
+ const dataName = fileBaseName ? `${fileBaseName}Data` : '';
263
+ const exportPrefix = dataName ? `window.${dataName} = ` : '';
264
+
246
265
  // Process ES6 exports to make the code evaluable
247
266
  let processedContent = depContent
248
267
  // Convert named exports: export const varName = ... → window.varName = ...
@@ -250,6 +269,8 @@ export default class Controller {
250
269
  .replace(/export\s+let\s+(\w+)\s*=\s*/g, 'window.$1 = ')
251
270
  .replace(/export\s+function\s+(\w+)/g, 'window.$1 = function')
252
271
  .replace(/export\s+default\s+/g, 'window.defaultExport = ')
272
+ // Promote default export to <file>Data for data modules
273
+ .replace(/window\.defaultExport\s*=\s*/g, exportPrefix || 'window.defaultExport = ')
253
274
  // Handle export { var1, var2 } statements
254
275
  .replace(/export\s*{\s*([^}]+)\s*}/g, (match, exportsStr) => {
255
276
  const exports = exportsStr.split(',').map(exp => exp.trim().split(' as ')[0].trim());
@@ -262,11 +283,42 @@ export default class Controller {
262
283
  new Function('slice', 'customElements', 'window', 'document', processedContent)
263
284
  (window.slice, window.customElements, window, window.document);
264
285
 
265
- processedDeps.add(depName);
286
+ // Apply import bindings to map local identifiers to globals
287
+ for (const binding of bindings) {
288
+ if (!binding?.localName) continue;
289
+
290
+ if (binding.type === 'default') {
291
+ if (!window[binding.localName]) {
292
+ const fallbackValue = dataName && window[dataName] !== undefined
293
+ ? window[dataName]
294
+ : window.defaultExport;
295
+ if (fallbackValue !== undefined) {
296
+ window[binding.localName] = fallbackValue;
297
+ }
298
+ }
299
+ }
300
+
301
+ if (binding.type === 'named') {
302
+ if (!window[binding.localName] && window[binding.importedName] !== undefined) {
303
+ window[binding.localName] = window[binding.importedName];
304
+ }
305
+ }
306
+
307
+ if (binding.type === 'namespace' && !window[binding.localName]) {
308
+ const namespace = {};
309
+ Object.keys(window).forEach((key) => {
310
+ namespace[key] = window[key];
311
+ });
312
+ window[binding.localName] = namespace;
313
+ }
314
+ }
315
+
316
+ processedDeps.add(depKey);
266
317
  console.log(`📄 External dependency loaded: ${depName}`);
267
318
  } catch (depError) {
268
319
  console.warn(`⚠️ Failed to load external dependency ${depName}:`, depError);
269
- console.warn('Original content preview:', depContent.substring(0, 200));
320
+ const preview = typeof depEntry === 'string' ? depEntry : depEntry.content;
321
+ console.warn('Original content preview:', preview.substring(0, 200));
270
322
  }
271
323
  }
272
324
  }
@@ -835,4 +887,4 @@ export default class Controller {
835
887
 
836
888
  return count;
837
889
  }
838
- }
890
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-web-framework",
3
- "version": "2.2.11",
3
+ "version": "2.2.13",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -1,196 +1,196 @@
1
- export default class HomePage extends HTMLElement {
2
- constructor(props) {
3
- super();
4
- slice.attachTemplate(this);
5
-
6
- this.$examplesContainer = this.querySelector('.examples-container');
7
-
8
- slice.controller.setComponentProps(this, props);
9
- this.debuggerProps = [];
10
- }
11
-
12
- async init() {
13
- // Crear la barra de navegación
14
- const navbar = await slice.build('Navbar', {
15
- position: 'fixed',
16
- logo: {
17
- src: '/images/Slice.js-logo.png',
18
- path: '/',
19
- },
20
- items: [
21
- { text: 'Home', path: '/' },
22
- { text: 'Playground', path: '/Playground' },
23
-
24
- ],
25
- buttons: [
26
- {
27
- value: 'Change Theme',
28
- onClickCallback: async () => {
29
- const currentTheme = slice.stylesManager.themeManager.currentTheme;
30
- if (currentTheme === 'Slice') {
31
- await slice.setTheme('Light');
32
- } else if (currentTheme === 'Light') {
33
- await slice.setTheme('Dark');
34
- } else {
35
- await slice.setTheme('Slice');
36
- }
37
- },
38
- },
39
- ],
40
- });
41
-
42
- // Crear botones para la sección de llamada a la acción
43
- const docsButton = await slice.build('Button', {
44
- value: 'Documentation',
45
- onClickCallback: () => //redirect to https://slice-js-docs.vercel.app/Documentation
46
- window.open('https://slice-js-docs.vercel.app/Documentation', '_blank'),
47
- customColor: {
48
- button: 'var(--primary-color)',
49
- label: 'var(--primary-color-contrast)'
50
- }
51
- });
52
-
53
- const componentsButton = await slice.build('Button', {
54
- value: 'Components Library',
55
- onClickCallback: () => window.open('https://slice-js-docs.vercel.app/Documentation/Visual', '_blank'),
56
- customColor: {
57
- button: 'var(--secondary-color)',
58
- label: 'var(--secondary-color-contrast)'
59
- }
60
- });
61
-
62
- // Añadir botones a la sección CTA
63
- this.querySelector('.cta-buttons').appendChild(docsButton);
64
- this.querySelector('.cta-buttons').appendChild(componentsButton);
65
-
66
- // Crear features section con un enfoque diferente (sin usar Cards)
67
- await this.createFeatures();
68
-
69
- // Crear ejemplos de componentes
70
- await this.createComponentExamples();
71
-
72
- // Configurar la sección de código de inicio
73
- await this.setupGettingStartedSection();
74
-
75
- // Añadir la barra de navegación al inicio del componente
76
- this.insertBefore(navbar, this.firstChild);
77
- }
78
-
79
- async createFeatures() {
80
- // Definir características
81
- const features = [
82
- {
83
- title: 'Component-Based',
84
- description: 'Build your app using modular, reusable components following web standards.'
85
- },
86
- {
87
- title: 'Zero Dependencies',
88
- description: 'Built with vanilla JavaScript. No external libraries required.'
89
- },
90
- {
91
- title: 'Easy Routing',
92
- description: 'Simple and powerful routing system for single page applications.'
93
- },
94
- {
95
- title: 'Theme System',
96
- description: 'Built-in theme support with easy customization through CSS variables.'
97
- },
98
- {
99
- title: 'Developer Tools',
100
- description: 'Integrated debugging and logging for faster development.'
101
- },
102
- {
103
- title: 'Performance Focused',
104
- description: 'Lightweight and optimized for fast loading and execution.'
105
- }
106
- ];
107
-
108
- const featureGrid = this.querySelector('.feature-grid');
109
-
110
- // Crear y añadir cada feature como un elemento HTML simple
111
- for (const feature of features) {
112
- const featureElement = document.createElement('div');
113
- featureElement.classList.add('feature-item');
114
-
115
- const featureTitle = document.createElement('h3');
116
- featureTitle.textContent = feature.title;
117
- featureTitle.classList.add('feature-title');
118
-
119
- const featureDescription = document.createElement('p');
120
- featureDescription.textContent = feature.description;
121
- featureDescription.classList.add('feature-description');
122
-
123
- featureElement.appendChild(featureTitle);
124
- featureElement.appendChild(featureDescription);
125
-
126
- featureGrid.appendChild(featureElement);
127
- }
128
- }
129
-
130
- async createComponentExamples() {
131
- // Crear ejemplos para demostrar componentes
132
- const inputExample = await slice.build('Input', {
133
- placeholder: 'Try typing here...',
134
- type: 'text'
135
- });
136
-
137
- const switchExample = await slice.build('Switch', {
138
- label: 'Toggle me',
139
- checked: true
140
- });
141
-
142
- const checkboxExample = await slice.build('Checkbox', {
143
- label: 'Check me',
144
- labelPlacement: 'right'
145
- });
146
-
147
- const detailsExample = await slice.build('Details', {
148
- title: 'Click to expand',
149
- text: 'This is a collapsible details component that can contain any content.'
150
- });
151
-
152
- // Crear sección para cada ejemplo
153
- const exampleSections = [
154
- { title: 'Input Component', component: inputExample },
155
- { title: 'Switch Component', component: switchExample },
156
- { title: 'Checkbox Component', component: checkboxExample },
157
- { title: 'Details Component', component: detailsExample }
158
- ];
159
-
160
- // Añadir cada ejemplo a la sección de ejemplos
161
- for (const section of exampleSections) {
162
- const container = document.createElement('div');
163
- container.classList.add('example-item');
164
-
165
- const title = document.createElement('h3');
166
- title.textContent = section.title;
167
-
168
- container.appendChild(title);
169
- container.appendChild(section.component);
170
-
171
- this.$examplesContainer.appendChild(container);
172
- }
173
- }
174
-
175
- async setupGettingStartedSection() {
176
- // Opcionalmente podríamos mejorar esta sección usando el CodeVisualizer component
177
- // en lugar del código HTML estático en el template
178
- const codeVisualizer = await slice.build('CodeVisualizer', {
179
- value: `// Initialize a new Slice.js project
180
- npm run slice:init
181
-
182
- // Create a new component
183
- npm run slice:create
184
-
185
- // Start your application
186
- npm run slice:start`,
187
- language: 'bash'
188
- });
189
-
190
- const codeSample = this.querySelector('.code-sample');
191
- codeSample.innerHTML = ''; // Clear the static code sample
192
- codeSample.appendChild(codeVisualizer);
193
- }
194
- }
195
-
1
+ export default class HomePage extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+
6
+ this.$examplesContainer = this.querySelector('.examples-container');
7
+
8
+ slice.controller.setComponentProps(this, props);
9
+ this.debuggerProps = [];
10
+ }
11
+
12
+ async init() {
13
+ // Crear la barra de navegación
14
+ const navbar = await slice.build('Navbar', {
15
+ position: 'fixed',
16
+ logo: {
17
+ src: '/images/Slice.js-logo.png',
18
+ path: '/',
19
+ },
20
+ items: [
21
+ { text: 'Home', path: '/' },
22
+ { text: 'Playground', path: '/Playground' },
23
+
24
+ ],
25
+ buttons: [
26
+ {
27
+ value: 'Change Theme',
28
+ onClickCallback: async () => {
29
+ const currentTheme = slice.stylesManager.themeManager.currentTheme;
30
+ if (currentTheme === 'Slice') {
31
+ await slice.setTheme('Light');
32
+ } else if (currentTheme === 'Light') {
33
+ await slice.setTheme('Dark');
34
+ } else {
35
+ await slice.setTheme('Slice');
36
+ }
37
+ },
38
+ },
39
+ ],
40
+ });
41
+
42
+ // Crear botones para la sección de llamada a la acción
43
+ const docsButton = await slice.build('Button', {
44
+ value: 'Documentation',
45
+ onClickCallback: () => //redirect to https://slice-js-docs.vercel.app/Documentation
46
+ window.open('https://slice-js-docs.vercel.app/Documentation', '_blank'),
47
+ customColor: {
48
+ button: 'var(--primary-color)',
49
+ label: 'var(--primary-color-contrast)'
50
+ }
51
+ });
52
+
53
+ const componentsButton = await slice.build('Button', {
54
+ value: 'Components Library',
55
+ onClickCallback: () => window.open('https://slice-js-docs.vercel.app/Documentation/Visual', '_blank'),
56
+ customColor: {
57
+ button: 'var(--secondary-color)',
58
+ label: 'var(--secondary-color-contrast)'
59
+ }
60
+ });
61
+
62
+ // Añadir botones a la sección CTA
63
+ this.querySelector('.cta-buttons').appendChild(docsButton);
64
+ this.querySelector('.cta-buttons').appendChild(componentsButton);
65
+
66
+ // Crear features section con un enfoque diferente (sin usar Cards)
67
+ await this.createFeatures();
68
+
69
+ // Crear ejemplos de componentes
70
+ await this.createComponentExamples();
71
+
72
+ // Configurar la sección de código de inicio
73
+ await this.setupGettingStartedSection();
74
+
75
+ // Añadir la barra de navegación al inicio del componente
76
+ this.insertBefore(navbar, this.firstChild);
77
+ }
78
+
79
+ async createFeatures() {
80
+ // Definir características
81
+ const features = [
82
+ {
83
+ title: 'Component-Based',
84
+ description: 'Build your app using modular, reusable components following web standards.'
85
+ },
86
+ {
87
+ title: 'Zero Dependencies',
88
+ description: 'Built with vanilla JavaScript. No external libraries required.'
89
+ },
90
+ {
91
+ title: 'Easy Routing',
92
+ description: 'Simple and powerful routing system for single page applications.'
93
+ },
94
+ {
95
+ title: 'Theme System',
96
+ description: 'Built-in theme support with easy customization through CSS variables.'
97
+ },
98
+ {
99
+ title: 'Developer Tools',
100
+ description: 'Integrated debugging and logging for faster development.'
101
+ },
102
+ {
103
+ title: 'Performance Focused',
104
+ description: 'Lightweight and optimized for fast loading and execution.'
105
+ }
106
+ ];
107
+
108
+ const featureGrid = this.querySelector('.feature-grid');
109
+
110
+ // Crear y añadir cada feature como un elemento HTML simple
111
+ for (const feature of features) {
112
+ const featureElement = document.createElement('div');
113
+ featureElement.classList.add('feature-item');
114
+
115
+ const featureTitle = document.createElement('h3');
116
+ featureTitle.textContent = feature.title;
117
+ featureTitle.classList.add('feature-title');
118
+
119
+ const featureDescription = document.createElement('p');
120
+ featureDescription.textContent = feature.description;
121
+ featureDescription.classList.add('feature-description');
122
+
123
+ featureElement.appendChild(featureTitle);
124
+ featureElement.appendChild(featureDescription);
125
+
126
+ featureGrid.appendChild(featureElement);
127
+ }
128
+ }
129
+
130
+ async createComponentExamples() {
131
+ // Crear ejemplos para demostrar componentes
132
+ const inputExample = await slice.build('Input', {
133
+ placeholder: 'Try typing here...',
134
+ type: 'text'
135
+ });
136
+
137
+ const switchExample = await slice.build('Switch', {
138
+ label: 'Toggle me',
139
+ checked: true
140
+ });
141
+
142
+ const checkboxExample = await slice.build('Checkbox', {
143
+ label: 'Check me',
144
+ labelPlacement: 'right'
145
+ });
146
+
147
+ const detailsExample = await slice.build('Details', {
148
+ title: 'Click to expand',
149
+ text: 'This is a collapsible details component that can contain any content.'
150
+ });
151
+
152
+ // Crear sección para cada ejemplo
153
+ const exampleSections = [
154
+ { title: 'Input Component', component: inputExample },
155
+ { title: 'Switch Component', component: switchExample },
156
+ { title: 'Checkbox Component', component: checkboxExample },
157
+ { title: 'Details Component', component: detailsExample }
158
+ ];
159
+
160
+ // Añadir cada ejemplo a la sección de ejemplos
161
+ for (const section of exampleSections) {
162
+ const container = document.createElement('div');
163
+ container.classList.add('example-item');
164
+
165
+ const title = document.createElement('h3');
166
+ title.textContent = section.title;
167
+
168
+ container.appendChild(title);
169
+ container.appendChild(section.component);
170
+
171
+ this.$examplesContainer.appendChild(container);
172
+ }
173
+ }
174
+
175
+ async setupGettingStartedSection() {
176
+ // Opcionalmente podríamos mejorar esta sección usando el CodeVisualizer component
177
+ // en lugar del código HTML estático en el template
178
+ const codeVisualizer = await slice.build('CodeVisualizer', {
179
+ value: `// Initialize a new Slice.js project
180
+ npm run slice:init
181
+
182
+ // Create a new component
183
+ npm run slice:create
184
+
185
+ // Start your application
186
+ npm run slice:start`,
187
+ language: 'bash'
188
+ });
189
+
190
+ const codeSample = this.querySelector('.code-sample');
191
+ codeSample.innerHTML = ''; // Clear the static code sample
192
+ codeSample.appendChild(codeVisualizer);
193
+ }
194
+ }
195
+
196
196
  customElements.define('slice-home-page', HomePage);
@@ -1,28 +1,28 @@
1
- const components = {
2
- "HomePage": "AppComponents",
3
- "Playground": "AppComponents",
4
- "Button": "Visual",
5
- "Card": "Visual",
6
- "Checkbox": "Visual",
7
- "CodeVisualizer": "Visual",
8
- "Details": "Visual",
9
- "DropDown": "Visual",
10
- "Grid": "Visual",
11
- "Icon": "Visual",
12
- "Input": "Visual",
13
- "Layout": "Visual",
14
- "Loading": "Visual",
15
- "MultiRoute": "Visual",
16
- "Navbar": "Visual",
17
- "NotFound": "Visual",
18
- "Route": "Visual",
19
- "Select": "Visual",
20
- "Switch": "Visual",
21
- "TreeItem": "Visual",
22
- "TreeView": "Visual",
23
- "FetchManager": "Service",
24
- "IndexedDbManager": "Service",
25
- "Link": "Service",
26
- "LocalStorageManager": "Service",
27
- "Translator": "Service"
1
+ const components = {
2
+ "HomePage": "AppComponents",
3
+ "Playground": "AppComponents",
4
+ "Button": "Visual",
5
+ "Card": "Visual",
6
+ "Checkbox": "Visual",
7
+ "CodeVisualizer": "Visual",
8
+ "Details": "Visual",
9
+ "DropDown": "Visual",
10
+ "Grid": "Visual",
11
+ "Icon": "Visual",
12
+ "Input": "Visual",
13
+ "Layout": "Visual",
14
+ "Loading": "Visual",
15
+ "MultiRoute": "Visual",
16
+ "Navbar": "Visual",
17
+ "NotFound": "Visual",
18
+ "Route": "Visual",
19
+ "Select": "Visual",
20
+ "Switch": "Visual",
21
+ "TreeItem": "Visual",
22
+ "TreeView": "Visual",
23
+ "FetchManager": "Service",
24
+ "IndexedDbManager": "Service",
25
+ "Link": "Service",
26
+ "LocalStorageManager": "Service",
27
+ "Translator": "Service"
28
28
  }; export default components;