slicejs-web-framework 3.3.0 → 3.3.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.
- package/Slice/Components/Structural/Controller/Controller.js +24 -26
- package/Slice/Components/Structural/Logger/Logger.js +0 -1
- package/Slice/Slice.js +5 -17
- package/api/framework/express.js +3 -0
- package/api/index.js +1 -1
- package/package.json +1 -1
- package/src/Components/components.js +4 -11
- package/src/Components/Service/FetchManager/FetchManager.js +0 -133
- package/src/Components/Service/IndexedDbManager/IndexedDbManager.js +0 -141
- package/src/Components/Service/LocalStorageManager/LocalStorageManager.js +0 -45
- package/src/Components/Visual/Button/Button.css +0 -47
- package/src/Components/Visual/Button/Button.html +0 -5
- package/src/Components/Visual/Button/Button.js +0 -93
- package/src/Components/Visual/Card/Card.css +0 -68
- package/src/Components/Visual/Card/Card.html +0 -7
- package/src/Components/Visual/Card/Card.js +0 -107
- package/src/Components/Visual/Checkbox/Checkbox.css +0 -87
- package/src/Components/Visual/Checkbox/Checkbox.html +0 -8
- package/src/Components/Visual/Checkbox/Checkbox.js +0 -86
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.css +0 -130
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.html +0 -4
- package/src/Components/Visual/CodeVisualizer/CodeVisualizer.js +0 -262
- package/src/Components/Visual/Details/Details.css +0 -70
- package/src/Components/Visual/Details/Details.html +0 -9
- package/src/Components/Visual/Details/Details.js +0 -76
- package/src/Components/Visual/DropDown/DropDown.css +0 -60
- package/src/Components/Visual/DropDown/DropDown.html +0 -5
- package/src/Components/Visual/DropDown/DropDown.js +0 -63
- package/src/Components/Visual/Grid/Grid.css +0 -7
- package/src/Components/Visual/Grid/Grid.html +0 -1
- package/src/Components/Visual/Grid/Grid.js +0 -57
- package/src/Components/Visual/Icon/Icon.css +0 -510
- package/src/Components/Visual/Icon/Icon.html +0 -1
- package/src/Components/Visual/Icon/Icon.js +0 -89
- package/src/Components/Visual/Icon/slc.eot +0 -0
- package/src/Components/Visual/Icon/slc.json +0 -555
- package/src/Components/Visual/Icon/slc.styl +0 -507
- package/src/Components/Visual/Icon/slc.svg +0 -1485
- package/src/Components/Visual/Icon/slc.symbol.svg +0 -1059
- package/src/Components/Visual/Icon/slc.ttf +0 -0
- package/src/Components/Visual/Icon/slc.woff +0 -0
- package/src/Components/Visual/Icon/slc.woff2 +0 -0
- package/src/Components/Visual/Input/Input.css +0 -91
- package/src/Components/Visual/Input/Input.html +0 -4
- package/src/Components/Visual/Input/Input.js +0 -215
- package/src/Components/Visual/Layout/Layout.css +0 -0
- package/src/Components/Visual/Layout/Layout.html +0 -0
- package/src/Components/Visual/Layout/Layout.js +0 -49
- package/src/Components/Visual/Link/Link.css +0 -8
- package/src/Components/Visual/Link/Link.html +0 -1
- package/src/Components/Visual/Link/Link.js +0 -63
- package/src/Components/Visual/Loading/Loading.css +0 -56
- package/src/Components/Visual/Loading/Loading.html +0 -83
- package/src/Components/Visual/Loading/Loading.js +0 -38
- package/src/Components/Visual/MultiRoute/MultiRoute.js +0 -100
- package/src/Components/Visual/Navbar/Navbar.css +0 -115
- package/src/Components/Visual/Navbar/Navbar.html +0 -44
- package/src/Components/Visual/Navbar/Navbar.js +0 -141
- package/src/Components/Visual/NotFound/NotFound.css +0 -117
- package/src/Components/Visual/NotFound/NotFound.html +0 -24
- package/src/Components/Visual/NotFound/NotFound.js +0 -16
- package/src/Components/Visual/Route/Route.js +0 -93
- package/src/Components/Visual/Select/Select.css +0 -84
- package/src/Components/Visual/Select/Select.html +0 -8
- package/src/Components/Visual/Select/Select.js +0 -195
- package/src/Components/Visual/Switch/Switch.css +0 -76
- package/src/Components/Visual/Switch/Switch.html +0 -8
- package/src/Components/Visual/Switch/Switch.js +0 -102
- package/src/Components/Visual/TreeItem/TreeItem.css +0 -36
- package/src/Components/Visual/TreeItem/TreeItem.html +0 -1
- package/src/Components/Visual/TreeItem/TreeItem.js +0 -126
- package/src/Components/Visual/TreeView/TreeView.css +0 -8
- package/src/Components/Visual/TreeView/TreeView.html +0 -1
- package/src/Components/Visual/TreeView/TreeView.js +0 -48
|
@@ -132,7 +132,7 @@ export default class Controller {
|
|
|
132
132
|
try {
|
|
133
133
|
const bundleInfo = this.getBundleInfo(resolvedBundleName);
|
|
134
134
|
if (!bundleInfo) {
|
|
135
|
-
|
|
135
|
+
slice.logger.logWarning('Controller', `Bundle ${resolvedBundleName} not found in configuration`);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -308,7 +308,7 @@ export default class Controller {
|
|
|
308
308
|
registerBundleLegacy(bundle) {
|
|
309
309
|
const { components, metadata } = bundle;
|
|
310
310
|
|
|
311
|
-
|
|
311
|
+
slice.logger.logInfo('Controller', `📦 Registering bundle: ${metadata.type} (${metadata.componentCount} components)`);
|
|
312
312
|
|
|
313
313
|
// Phase 1: Register templates and CSS for all components first
|
|
314
314
|
for (const [componentName, componentData] of Object.entries(components)) {
|
|
@@ -329,7 +329,7 @@ export default class Controller {
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
} catch (error) {
|
|
332
|
-
|
|
332
|
+
slice.logger.logError('Controller', `❌ Failed to register assets for ${componentName}`, error);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
@@ -369,8 +369,8 @@ export default class Controller {
|
|
|
369
369
|
window.document
|
|
370
370
|
);
|
|
371
371
|
} catch (evalError) {
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
slice.logger.logWarning('Controller', `❌ Failed to evaluate processed dependency ${depName}: ${evalError}`);
|
|
373
|
+
slice.logger.logWarning('Controller', `Processed content preview: ${processedContent.substring(0, 200)}`);
|
|
374
374
|
// Try evaluating the original content as fallback
|
|
375
375
|
try {
|
|
376
376
|
new Function('slice', 'customElements', 'window', 'document', depContent)(
|
|
@@ -379,16 +379,16 @@ export default class Controller {
|
|
|
379
379
|
window,
|
|
380
380
|
window.document
|
|
381
381
|
);
|
|
382
|
-
|
|
382
|
+
slice.logger.logInfo('Controller', `✅ Fallback evaluation succeeded for ${depName}`);
|
|
383
383
|
} catch (fallbackError) {
|
|
384
|
-
|
|
384
|
+
slice.logger.logWarning('Controller', `❌ Fallback evaluation also failed for ${depName}: ${fallbackError}`);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
processedDeps.add(depName);
|
|
389
|
-
|
|
389
|
+
slice.logger.logInfo('Controller', `📄 Dependency loaded: ${depName}`);
|
|
390
390
|
} catch (depError) {
|
|
391
|
-
|
|
391
|
+
slice.logger.logWarning('Controller', `⚠️ Failed to load dependency ${depName} for ${componentName}: ${depError}`);
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
}
|
|
@@ -443,11 +443,11 @@ export default class Controller {
|
|
|
443
443
|
|
|
444
444
|
if (componentClass) {
|
|
445
445
|
this.classes.set(componentName, componentClass);
|
|
446
|
-
|
|
446
|
+
slice.logger.logInfo('Controller', `📝 Class registered for: ${componentName}`);
|
|
447
447
|
}
|
|
448
448
|
} catch (error) {
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
slice.logger.logWarning('Controller', `❌ Failed to evaluate class for ${componentName}: ${error}`);
|
|
450
|
+
slice.logger.logWarning('Controller', `Code that failed: ${componentData.js.substring(0, 200) + '...'}`);
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
}
|
|
@@ -459,7 +459,7 @@ export default class Controller {
|
|
|
459
459
|
registerBundle(bundle) {
|
|
460
460
|
const validation = this.validateBundle(bundle);
|
|
461
461
|
if (!validation.isValid) {
|
|
462
|
-
|
|
462
|
+
slice.logger.logWarning('Controller', `❌ Bundle validation failed: ${validation.error}`);
|
|
463
463
|
return Promise.resolve(false);
|
|
464
464
|
}
|
|
465
465
|
|
|
@@ -474,7 +474,7 @@ export default class Controller {
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
|
|
477
|
+
slice.logger.logInfo('Controller', `📦 Registering bundle: ${metadata.type} (${metadata.componentCount} components)`);
|
|
478
478
|
|
|
479
479
|
const entries = Object.entries(components);
|
|
480
480
|
const chunkSize = 50;
|
|
@@ -505,22 +505,20 @@ export default class Controller {
|
|
|
505
505
|
: componentName;
|
|
506
506
|
this.classes.set(registeredName, componentData.class);
|
|
507
507
|
if (componentName === 'Loading') {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
});
|
|
508
|
+
slice.logger.logInfo(
|
|
509
|
+
'Controller',
|
|
510
|
+
`🔎 Bundle class registered: Loading (registeredName=${registeredName}, type=${typeof componentData.class}, isFunction=${typeof componentData.class === 'function'})`
|
|
511
|
+
);
|
|
513
512
|
}
|
|
514
513
|
if (componentName === 'InputSearchDocs' || componentName === 'MainMenu') {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
});
|
|
514
|
+
slice.logger.logInfo(
|
|
515
|
+
'Controller',
|
|
516
|
+
`🔎 Bundle class registered: ${componentName} (registeredName=${registeredName}, type=${typeof componentData.class}, isFunction=${typeof componentData.class === 'function'})`
|
|
517
|
+
);
|
|
520
518
|
}
|
|
521
519
|
}
|
|
522
520
|
} catch (error) {
|
|
523
|
-
|
|
521
|
+
slice.logger.logError('Controller', `❌ Failed to register component ${componentName}`, error);
|
|
524
522
|
}
|
|
525
523
|
}
|
|
526
524
|
|
|
@@ -534,7 +532,7 @@ export default class Controller {
|
|
|
534
532
|
return;
|
|
535
533
|
}
|
|
536
534
|
|
|
537
|
-
|
|
535
|
+
slice.logger.logInfo('Controller', `✅ Bundle registration completed: ${metadata.componentCount} components processed`);
|
|
538
536
|
resolve(true);
|
|
539
537
|
};
|
|
540
538
|
|
package/Slice/Slice.js
CHANGED
|
@@ -161,7 +161,7 @@ export default class Slice {
|
|
|
161
161
|
|
|
162
162
|
// 📦 If component is from bundle but not in cache, it should have been registered by registerBundle
|
|
163
163
|
if (isFromBundle) {
|
|
164
|
-
|
|
164
|
+
this.logger.logInfo('Slice', `📦 Using bundled component: ${componentName}`);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (html || html === '') {
|
|
@@ -181,7 +181,6 @@ export default class Slice {
|
|
|
181
181
|
this.logger.logInfo('Slice', `CSS ${componentName} loaded`);
|
|
182
182
|
}
|
|
183
183
|
} catch (error) {
|
|
184
|
-
console.log(error);
|
|
185
184
|
this.logger.logError('Slice', `Error loading resources for ${componentName}`, error);
|
|
186
185
|
return null;
|
|
187
186
|
}
|
|
@@ -196,20 +195,10 @@ export default class Slice {
|
|
|
196
195
|
delete props.sliceId;
|
|
197
196
|
|
|
198
197
|
const ComponentClass = this.controller.classes.get(componentName);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
classValue: ComponentClass
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (componentName === 'InputSearchDocs' || componentName === 'MainMenu') {
|
|
207
|
-
console.log(`🔎 Build component: ${componentName}`, {
|
|
208
|
-
classType: typeof ComponentClass,
|
|
209
|
-
isFunction: typeof ComponentClass === 'function',
|
|
210
|
-
classValue: ComponentClass
|
|
211
|
-
});
|
|
212
|
-
}
|
|
198
|
+
this.logger.logInfo(
|
|
199
|
+
'Slice',
|
|
200
|
+
`🔎 Build component: ${componentName} (classType: ${typeof ComponentClass}, isFunction: ${typeof ComponentClass === 'function'})`
|
|
201
|
+
);
|
|
213
202
|
const componentInstance = new ComponentClass(props);
|
|
214
203
|
|
|
215
204
|
if (componentIds.id && isVisual) componentInstance.id = componentIds.id;
|
|
@@ -234,7 +223,6 @@ export default class Slice {
|
|
|
234
223
|
this.logger.logInfo('Slice', `Instance ${componentInstance.sliceId} created`);
|
|
235
224
|
return componentInstance;
|
|
236
225
|
} catch (error) {
|
|
237
|
-
console.log(error);
|
|
238
226
|
this.logger.logError('Slice', `Error creating instance ${componentName}`, error);
|
|
239
227
|
return null;
|
|
240
228
|
}
|
package/api/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
// Template registry: only the AppComponents the starter ships in-tree.
|
|
2
|
+
// Visual and Service components are installed from the registry by `slice init`
|
|
3
|
+
// (and any later `slice get`), which registers them here automatically.
|
|
1
4
|
const components = {
|
|
2
5
|
"AppShell": "AppComponents",
|
|
3
6
|
"HomeSection": "AppComponents",
|
|
4
|
-
"AboutSection": "AppComponents"
|
|
5
|
-
"Button": "Visual",
|
|
6
|
-
"Link": "Visual",
|
|
7
|
-
"Loading": "Visual",
|
|
8
|
-
"MultiRoute": "Visual",
|
|
9
|
-
"Navbar": "Visual",
|
|
10
|
-
"NotFound": "Visual",
|
|
11
|
-
"Route": "Visual",
|
|
12
|
-
"FetchManager": "Service",
|
|
13
|
-
"IndexedDbManager": "Service",
|
|
14
|
-
"LocalStorageManager": "Service"
|
|
7
|
+
"AboutSection": "AppComponents"
|
|
15
8
|
}; export default components;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
export default class FetchManager {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
const { baseUrl, timeout } = props;
|
|
4
|
-
if (baseUrl !== undefined) {
|
|
5
|
-
this.baseUrl = baseUrl;
|
|
6
|
-
}
|
|
7
|
-
this.methods = ['GET', 'POST', 'PUT', 'DELETE'];
|
|
8
|
-
this.lastRequest = null;
|
|
9
|
-
this.cacheEnabled = false;
|
|
10
|
-
this.defaultHeaders = {};
|
|
11
|
-
timeout ? (this.timeout = timeout) : (this.timeout = 10000);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async request(
|
|
15
|
-
method,
|
|
16
|
-
data,
|
|
17
|
-
endpoint,
|
|
18
|
-
onRequestSuccess,
|
|
19
|
-
onRequestError,
|
|
20
|
-
refetchOnError = false,
|
|
21
|
-
requestOptions = {}
|
|
22
|
-
) {
|
|
23
|
-
if (!this.methods.includes(method)) throw new Error('Invalid method');
|
|
24
|
-
if (data && typeof data !== 'object') throw new Error('Invalid data, not JSON');
|
|
25
|
-
const controller = new AbortController();
|
|
26
|
-
|
|
27
|
-
let options;
|
|
28
|
-
if (method !== 'GET') {
|
|
29
|
-
options = {
|
|
30
|
-
method: method,
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
...this.defaultHeaders,
|
|
34
|
-
...requestOptions.headers,
|
|
35
|
-
},
|
|
36
|
-
signal: controller.signal,
|
|
37
|
-
};
|
|
38
|
-
} else {
|
|
39
|
-
options = {
|
|
40
|
-
method: method,
|
|
41
|
-
headers: {
|
|
42
|
-
...this.defaultHeaders,
|
|
43
|
-
...requestOptions.headers,
|
|
44
|
-
},
|
|
45
|
-
signal: controller.signal,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (data) {
|
|
50
|
-
options.body = JSON.stringify(data);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let loading;
|
|
54
|
-
if (!slice.controller.getComponent('Loading')) {
|
|
55
|
-
loading = await slice.build('Loading', { sliceId: 'Loading' });
|
|
56
|
-
} else {
|
|
57
|
-
loading = slice.controller.getComponent('Loading');
|
|
58
|
-
}
|
|
59
|
-
loading.start();
|
|
60
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout || 10000);
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
let response;
|
|
64
|
-
|
|
65
|
-
// Check if cache is enabled and a cached response exists
|
|
66
|
-
if (this.cacheEnabled && this.lastRequest && this.lastRequest.endpoint === endpoint) {
|
|
67
|
-
return this.lastRequest.response;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (this.baseUrl !== undefined) {
|
|
71
|
-
response = await fetch(this.baseUrl + endpoint, options);
|
|
72
|
-
} else {
|
|
73
|
-
response = await fetch(endpoint, options);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (response.ok) {
|
|
77
|
-
if (typeof onRequestSuccess === 'function') {
|
|
78
|
-
onRequestSuccess(data, response);
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
if (typeof onRequestError === 'function') {
|
|
82
|
-
onRequestError(data, response);
|
|
83
|
-
}
|
|
84
|
-
if (refetchOnError) {
|
|
85
|
-
// Retry the request in case of error
|
|
86
|
-
return await this.request(
|
|
87
|
-
method,
|
|
88
|
-
data,
|
|
89
|
-
endpoint,
|
|
90
|
-
onRequestSuccess,
|
|
91
|
-
onRequestError,
|
|
92
|
-
refetchOnError,
|
|
93
|
-
requestOptions
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let output = await response.json();
|
|
99
|
-
loading.stop();
|
|
100
|
-
|
|
101
|
-
// Cache the response if cache is enabled
|
|
102
|
-
if (this.cacheEnabled) {
|
|
103
|
-
this.lastRequest = { data, response, endpoint };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return output;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (error.message === 'Failed to fetch') {
|
|
109
|
-
slice.logger.logError('Se perdió la conexión a internet');
|
|
110
|
-
} else {
|
|
111
|
-
console.error('Error al realizar la solicitud:', error);
|
|
112
|
-
}
|
|
113
|
-
loading.stop();
|
|
114
|
-
throw error;
|
|
115
|
-
} finally {
|
|
116
|
-
clearTimeout(timeoutId);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Enable or disable caching of responses
|
|
121
|
-
enableCache() {
|
|
122
|
-
this.cacheEnabled = true;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
disableCache() {
|
|
126
|
-
this.cacheEnabled = false;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Set default headers for all requests
|
|
130
|
-
setDefaultHeaders(headers) {
|
|
131
|
-
this.defaultHeaders = headers;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export default class IndexedDbManager {
|
|
2
|
-
constructor(databaseName, storeName) {
|
|
3
|
-
this.databaseName = databaseName;
|
|
4
|
-
this.storeName = storeName;
|
|
5
|
-
this.db = null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
async openDatabase() {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const request = indexedDB.open(this.databaseName);
|
|
11
|
-
|
|
12
|
-
request.onupgradeneeded = (event) => {
|
|
13
|
-
const db = event.target.result;
|
|
14
|
-
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
15
|
-
db.createObjectStore(this.storeName, {
|
|
16
|
-
keyPath: 'id',
|
|
17
|
-
autoIncrement: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
request.onsuccess = (event) => {
|
|
23
|
-
this.db = event.target.result;
|
|
24
|
-
resolve(this.db);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
request.onerror = (event) => {
|
|
28
|
-
reject(new Error(`Error opening IndexedDB: ${event.target.error}`));
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
closeDatabase() {
|
|
34
|
-
if (this.db) {
|
|
35
|
-
this.db.close();
|
|
36
|
-
this.db = null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async addItem(item) {
|
|
41
|
-
const db = await this.openDatabase();
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
const transaction = db.transaction([this.storeName], 'readwrite');
|
|
44
|
-
const store = transaction.objectStore(this.storeName);
|
|
45
|
-
const request = store.add(item);
|
|
46
|
-
|
|
47
|
-
request.onsuccess = () => {
|
|
48
|
-
resolve(request.result);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
request.onerror = (event) => {
|
|
52
|
-
reject(new Error(`Error adding item to IndexedDB: ${event.target.error}`));
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async updateItem(item) {
|
|
58
|
-
const db = await this.openDatabase();
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
const transaction = db.transaction([this.storeName], 'readwrite');
|
|
61
|
-
const store = transaction.objectStore(this.storeName);
|
|
62
|
-
const request = store.put(item);
|
|
63
|
-
|
|
64
|
-
request.onsuccess = () => {
|
|
65
|
-
resolve(request.result);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
request.onerror = (event) => {
|
|
69
|
-
reject(new Error(`Error updating item in IndexedDB: ${event.target.error}`));
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async getItem(id) {
|
|
75
|
-
const db = await this.openDatabase();
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
const transaction = db.transaction([this.storeName], 'readonly');
|
|
78
|
-
const store = transaction.objectStore(this.storeName);
|
|
79
|
-
const request = store.get(id);
|
|
80
|
-
|
|
81
|
-
request.onsuccess = () => {
|
|
82
|
-
resolve(request.result);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
request.onerror = (event) => {
|
|
86
|
-
reject(new Error(`Error getting item from IndexedDB: ${event.target.error}`));
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async deleteItem(id) {
|
|
92
|
-
const db = await this.openDatabase();
|
|
93
|
-
return new Promise((resolve, reject) => {
|
|
94
|
-
const transaction = db.transaction([this.storeName], 'readwrite');
|
|
95
|
-
const store = transaction.objectStore(this.storeName);
|
|
96
|
-
const request = store.delete(id);
|
|
97
|
-
|
|
98
|
-
request.onsuccess = () => {
|
|
99
|
-
resolve();
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
request.onerror = (event) => {
|
|
103
|
-
reject(new Error(`Error deleting item from IndexedDB: ${event.target.error}`));
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async getAllItems() {
|
|
109
|
-
const db = await this.openDatabase();
|
|
110
|
-
return new Promise((resolve, reject) => {
|
|
111
|
-
const transaction = db.transaction([this.storeName], 'readonly');
|
|
112
|
-
const store = transaction.objectStore(this.storeName);
|
|
113
|
-
const request = store.getAll();
|
|
114
|
-
|
|
115
|
-
request.onsuccess = () => {
|
|
116
|
-
resolve(request.result);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
request.onerror = (event) => {
|
|
120
|
-
reject(new Error(`Error getting items from IndexedDB: ${event.target.error}`));
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async clearItems() {
|
|
126
|
-
const db = await this.openDatabase();
|
|
127
|
-
return new Promise((resolve, reject) => {
|
|
128
|
-
const transaction = db.transaction([this.storeName], 'readwrite');
|
|
129
|
-
const store = transaction.objectStore(this.storeName);
|
|
130
|
-
const request = store.clear();
|
|
131
|
-
|
|
132
|
-
request.onsuccess = () => {
|
|
133
|
-
resolve();
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
request.onerror = (event) => {
|
|
137
|
-
reject(new Error(`Error clearing items in IndexedDB: ${event.target.error}`));
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export default class LocalStorageManager {
|
|
2
|
-
constructor() {
|
|
3
|
-
// No se necesitan propiedades en este caso
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
getItem(key) {
|
|
7
|
-
try {
|
|
8
|
-
const item = localStorage.getItem(key);
|
|
9
|
-
return item ? JSON.parse(item) : null;
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.error(`Error getting item from localStorage: ${error.message}`);
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
setItem(key, value) {
|
|
17
|
-
try {
|
|
18
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
19
|
-
return true;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error(`Error setting item in localStorage: ${error.message}`);
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
removeItem(key) {
|
|
27
|
-
try {
|
|
28
|
-
localStorage.removeItem(key);
|
|
29
|
-
return true;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(`Error removing item from localStorage: ${error.message}`);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
clear() {
|
|
37
|
-
try {
|
|
38
|
-
localStorage.clear();
|
|
39
|
-
return true;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error(`Error clearing localStorage: ${error.message}`);
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
.slice_button_container {
|
|
2
|
-
padding: 10px;
|
|
3
|
-
}
|
|
4
|
-
.slice_button_value {
|
|
5
|
-
user-select: none;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
}
|
|
8
|
-
.slice_button {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
cursor: pointer;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
position: relative;
|
|
15
|
-
max-width: fit-content;
|
|
16
|
-
background-color: var(--primary-color);
|
|
17
|
-
color: var(--primary-color-contrast);
|
|
18
|
-
border-radius: var(--border-radius-slice);
|
|
19
|
-
border: var(--slice-border) solid var(--primary-color);
|
|
20
|
-
font-weight: 800;
|
|
21
|
-
min-width: 100%;
|
|
22
|
-
padding: 10px;
|
|
23
|
-
-webkit-transition-duration: 0.4s; /* Safari */
|
|
24
|
-
transition-duration: 0.4s;
|
|
25
|
-
}
|
|
26
|
-
.slice_button:after {
|
|
27
|
-
content: "";
|
|
28
|
-
width: 100%;
|
|
29
|
-
height: 100%;
|
|
30
|
-
border-radius: 100%;
|
|
31
|
-
background: #ffffff50;
|
|
32
|
-
position: absolute;
|
|
33
|
-
display: block;
|
|
34
|
-
opacity: 0;
|
|
35
|
-
scale: 10;
|
|
36
|
-
transition: all 1s;
|
|
37
|
-
}
|
|
38
|
-
.slice_button:active {
|
|
39
|
-
transform: translateY(5px);
|
|
40
|
-
}
|
|
41
|
-
.slice_button:active:after {
|
|
42
|
-
scale: 0;
|
|
43
|
-
padding: 0;
|
|
44
|
-
margin: 0;
|
|
45
|
-
opacity: 1;
|
|
46
|
-
transition: 0s;
|
|
47
|
-
}
|