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.
Files changed (36) hide show
  1. package/.opencode/opencode.json +14 -0
  2. package/README.md +57 -134
  3. package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +233 -110
  4. package/Slice/Components/Structural/Controller/Controller.js +9 -0
  5. package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -0
  6. package/Slice/Components/Structural/Debugger/Debugger.js +392 -442
  7. package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +264 -149
  8. package/Slice/Components/Structural/Router/Router.js +45 -14
  9. package/Slice/tests/props-allowed-values-validation.test.js +119 -0
  10. package/package.json +11 -9
  11. package/src/App/index.html +2 -8
  12. package/src/App/index.js +18 -21
  13. package/src/App/style.css +8 -37
  14. package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -0
  15. package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -0
  16. package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -0
  17. package/src/Components/AppComponents/AppShell/AppShell.css +10 -0
  18. package/src/Components/AppComponents/AppShell/AppShell.html +4 -0
  19. package/src/Components/AppComponents/AppShell/AppShell.js +36 -0
  20. package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -0
  21. package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -0
  22. package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -0
  23. package/src/Components/Visual/MultiRoute/MultiRoute.js +13 -6
  24. package/src/Components/components.js +4 -16
  25. package/src/routes.js +6 -12
  26. package/src/sliceConfig.json +2 -1
  27. package/Slice/Components/Structural/Debugger/Debugger.css +0 -620
  28. package/src/Components/AppComponents/HomePage/HomePage.css +0 -201
  29. package/src/Components/AppComponents/HomePage/HomePage.html +0 -37
  30. package/src/Components/AppComponents/HomePage/HomePage.js +0 -210
  31. package/src/Components/AppComponents/Playground/Playground.css +0 -12
  32. package/src/Components/AppComponents/Playground/Playground.html +0 -0
  33. package/src/Components/AppComponents/Playground/Playground.js +0 -111
  34. package/src/images/Slice.js-logo.png +0 -0
  35. package/src/images/im2/Slice.js-logo.png +0 -0
  36. package/src/testing.js +0 -888
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "slicejs-web-framework",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=20"
7
7
  },
8
8
  "scripts": {
9
+ "dev": "node ./node_modules/slicejs-cli/client.js dev",
10
+ "build": "node ./node_modules/slicejs-cli/client.js build",
11
+ "start": "node ./node_modules/slicejs-cli/client.js start",
9
12
  "test": "echo \"Error: no test specified\" && exit 1",
10
- "slice:init": "node node_modules/slicejs-cli/client.js init",
11
- "slice:create": "node node_modules/slicejs-cli/client.js component create",
12
- "slice:delete": "node node_modules/slicejs-cli/client.js component delete",
13
- "slice:list": "node node_modules/slicejs-cli/client.js component list",
14
- "slice:start": "node api/index.js",
13
+ "slice:init": "node ./node_modules/slicejs-cli/client.js init",
14
+ "slice:create": "node ./node_modules/slicejs-cli/client.js component create",
15
+ "slice:delete": "node ./node_modules/slicejs-cli/client.js component delete",
16
+ "slice:list": "node ./node_modules/slicejs-cli/client.js component list",
17
+ "slice:start": "node ./node_modules/slicejs-cli/client.js start",
15
18
  "format": "prettier --write \"**/*.js\"",
16
- "run": "node api/index.js",
17
- "development": "npm run",
18
- "slice:modify": "node node_modules/slicejs-cli/client.js modify"
19
+ "run": "node ./node_modules/slicejs-cli/client.js dev",
20
+ "slice:modify": "node ./node_modules/slicejs-cli/client.js modify"
19
21
  },
20
22
  "keywords": [],
21
23
  "author": "",
@@ -3,15 +3,9 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Slice - Documentation</title>
7
- <link rel="icon" type="image/x-icon" href="/../../images/favicon.ico" />
6
+ <title>Slice App</title>
7
+ <link rel="icon" type="image/x-icon" href="/images/favicon.ico" />
8
8
  <link rel="stylesheet" type="text/css" href="/App/style.css" />
9
-
10
- <!-- Prism -->
11
-
12
-
13
-
14
- <!-- Eliminar Prism despues-->
15
9
  </head>
16
10
 
17
11
  <body>
package/src/App/index.js CHANGED
@@ -1,23 +1,20 @@
1
1
  import Slice from '/Slice/Slice.js';
2
2
 
3
-
4
- /*
5
- slice.router.beforeEach(async (to, from, next) => {
6
-
7
- if(to.metadata.private){
8
- const isAuthenticated = await //fetchlogic for validation
9
- if(!isAuthenticated){
10
- return next({ path: '/login', replace: true });
11
- }
12
- return next();
13
- }
14
-
15
- return next();
16
- });
17
-
18
-
19
- If any beforeEach or afterEach is defined, start the router after defining them
20
-
21
- await slice.router.start();
22
-
23
- */
3
+ // `slice` is now a global. Routes are declared in /routes.js and the router
4
+ // auto-starts shortly after load, so this file can stay almost empty.
5
+ //
6
+ // If you need navigation guards (auth, page titles, analytics), define them
7
+ // here and then start the router EXPLICITLY (this cancels the auto-start):
8
+ //
9
+ // slice.router.beforeEach(async (to, from, next) => {
10
+ // if (to.metadata?.private && !slice.context.getState('auth')?.isLoggedIn) {
11
+ // return next({ path: '/login', replace: true });
12
+ // }
13
+ // next();
14
+ // });
15
+ //
16
+ // slice.router.afterEach((to) => {
17
+ // document.title = to.metadata?.title ?? 'Slice App';
18
+ // });
19
+ //
20
+ // await slice.router.start();
package/src/App/style.css CHANGED
@@ -1,40 +1,11 @@
1
- /* :root {
2
- --docs-width: 64%;
3
- }
4
- slice-layout {
5
- display: flex;
6
- justify-content: center;
7
- }
8
-
9
- p {
10
- text-align: justify;
11
- }
12
- h1 {
13
- padding-top: 10px;
14
- padding-bottom: 10px;
15
- border-bottom: 1px solid var(--secondary-background-color);
16
- }
17
- h2 {
18
- padding-top: 10px;
19
- }
20
- .grid-container {
21
- overflow-x: auto;
22
- }
23
- @media only screen and (max-width: 770px) {
24
- :root {
25
- --docs-width: 100%;
26
- }
27
- }
1
+ /* App-level base styles. Component styles live in each component's own .css. */
28
2
  * {
29
- font-family: var(--font-family);
3
+ box-sizing: border-box;
4
+ font-family: var(--font-family, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
30
5
  }
31
- .docs_container {
6
+
7
+ body {
8
+ margin: 0;
9
+ background: var(--primary-background-color);
32
10
  color: var(--font-primary-color);
33
- margin-top: 100px;
34
- overflow-y: scroll;
35
- overflow-x: hidden;
36
- width: var(--docs-width);
37
- padding-left: 10px;
38
- padding-right: 10px;
39
- padding-bottom: 25px;
40
- } */
11
+ }
@@ -0,0 +1,9 @@
1
+ .about {
2
+ padding: 16px 0;
3
+ }
4
+
5
+ .about p {
6
+ color: var(--font-secondary-color);
7
+ max-width: 65ch;
8
+ line-height: 1.6;
9
+ }
@@ -0,0 +1,8 @@
1
+ <section class="about">
2
+ <h1>About</h1>
3
+ <p>
4
+ This starter uses the App Shell + MultiRoute pattern: a persistent shell (the navbar)
5
+ wraps a content area that swaps sections by URL. See the docs — Project Anatomy,
6
+ Your First Page, and The Development Loop — to learn the recommended workflow.
7
+ </p>
8
+ </section>
@@ -0,0 +1,12 @@
1
+ export default class AboutSection extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+ slice.controller.setComponentProps(this, props);
6
+ }
7
+
8
+ // A static section needs no init(). Add async init() if it fetches data,
9
+ // and update() if it should refresh when revisited (MultiRoute caches it).
10
+ }
11
+
12
+ customElements.define('slice-about-section', AboutSection);
@@ -0,0 +1,10 @@
1
+ .app-shell {
2
+ min-height: 100vh;
3
+ }
4
+
5
+ .app-shell__content {
6
+ max-width: 960px;
7
+ margin: 0 auto;
8
+ /* top padding clears the fixed navbar */
9
+ padding: 96px 24px 48px;
10
+ }
@@ -0,0 +1,4 @@
1
+ <div class="app-shell">
2
+ <header class="app-shell__header"></header>
3
+ <main class="app-shell__content"></main>
4
+ </div>
@@ -0,0 +1,36 @@
1
+ export default class AppShell extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+ this.$header = this.querySelector('.app-shell__header');
6
+ this.$content = this.querySelector('.app-shell__content');
7
+ slice.controller.setComponentProps(this, props);
8
+ }
9
+
10
+ async init() {
11
+ // Persistent navbar — built once, stays across navigations.
12
+ const navbar = await slice.build('Navbar', {
13
+ sliceId: 'app-navbar',
14
+ position: 'fixed',
15
+ items: [
16
+ { text: 'Home', path: '/' },
17
+ { text: 'About', path: '/about' }
18
+ ]
19
+ });
20
+ this.$header.appendChild(navbar);
21
+
22
+ // Content area — a MultiRoute swaps the matching section by URL.
23
+ // MultiRoute caches each section instance, so give sections an update()
24
+ // method if they show dynamic data.
25
+ const content = await slice.build('MultiRoute', {
26
+ sliceId: 'app-content',
27
+ routes: [
28
+ { path: '/', component: 'HomeSection' },
29
+ { path: '/about', component: 'AboutSection' }
30
+ ]
31
+ });
32
+ this.$content.appendChild(content);
33
+ }
34
+ }
35
+
36
+ customElements.define('slice-app-shell', AppShell);
@@ -0,0 +1,20 @@
1
+ .home {
2
+ text-align: center;
3
+ padding: 32px 0;
4
+ }
5
+
6
+ .home__title {
7
+ font-size: 2rem;
8
+ margin-bottom: 12px;
9
+ }
10
+
11
+ .home__lead {
12
+ color: var(--font-secondary-color);
13
+ max-width: 60ch;
14
+ margin: 0 auto 24px;
15
+ line-height: 1.6;
16
+ }
17
+
18
+ .home__lead code {
19
+ color: var(--font-primary-color);
20
+ }
@@ -0,0 +1,10 @@
1
+ <section class="home">
2
+ <h1 class="home__title">Welcome to your Slice app</h1>
3
+ <p class="home__lead">
4
+ This is the App Shell + MultiRoute starter. Edit
5
+ <code>src/Components/AppComponents/HomeSection/</code> to change this page, or add a
6
+ section: create an AppComponent, then register it in <code>src/routes.js</code> and in
7
+ the AppShell's MultiRoute.
8
+ </p>
9
+ <div class="home__cta"></div>
10
+ </section>
@@ -0,0 +1,19 @@
1
+ export default class HomeSection extends HTMLElement {
2
+ constructor(props) {
3
+ super();
4
+ slice.attachTemplate(this);
5
+ this.$cta = this.querySelector('.home__cta');
6
+ slice.controller.setComponentProps(this, props);
7
+ }
8
+
9
+ async init() {
10
+ // Build child components with slice.build (always await).
11
+ const button = await slice.build('Button', {
12
+ value: 'Go to About',
13
+ onClickCallback: () => slice.router.navigate('/about')
14
+ });
15
+ this.$cta.appendChild(button);
16
+ }
17
+ }
18
+
19
+ customElements.define('slice-home-section', HomeSection);
@@ -27,9 +27,18 @@ export default class MultiRoute extends HTMLElement {
27
27
  */
28
28
  }
29
29
 
30
+ // Find the route whose path matches the current URL, case-insensitively.
31
+ // '/About' matches a route declared as '/about'. (Dynamic params like ${id}
32
+ // are still resolved by the top-level router, not by MultiRoute.)
33
+ matchRoute() {
34
+ const currentPath = window.location.pathname.toLowerCase();
35
+ return this.props.routes.find(
36
+ (route) => typeof route.path === 'string' && route.path.toLowerCase() === currentPath
37
+ );
38
+ }
39
+
30
40
  async render() {
31
- const currentPath = window.location.pathname;
32
- const routeMatch = this.props.routes.find((route) => route.path === currentPath);
41
+ const routeMatch = this.matchRoute();
33
42
 
34
43
  if (routeMatch) {
35
44
  const { component } = routeMatch;
@@ -68,8 +77,7 @@ export default class MultiRoute extends HTMLElement {
68
77
  }
69
78
 
70
79
  async renderIfCurrentRoute() {
71
- const currentPath = window.location.pathname;
72
- const routeMatch = this.props.routes.find((route) => route.path === currentPath);
80
+ const routeMatch = this.matchRoute();
73
81
 
74
82
  if (routeMatch) {
75
83
  await this.render(); // Llamamos a render() para manejar el renderizado desde la caché si es necesario
@@ -79,8 +87,7 @@ export default class MultiRoute extends HTMLElement {
79
87
  }
80
88
 
81
89
  removeComponent() {
82
- const currentPath = window.location.pathname;
83
- const routeMatch = this.props.routes.find((route) => route.path === currentPath);
90
+ const routeMatch = this.matchRoute();
84
91
 
85
92
  if (routeMatch) {
86
93
  const { component } = routeMatch;
@@ -1,26 +1,14 @@
1
1
  const components = {
2
- "HomePage": "AppComponents",
3
- "Playground": "AppComponents",
2
+ "AppShell": "AppComponents",
3
+ "HomeSection": "AppComponents",
4
+ "AboutSection": "AppComponents",
4
5
  "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",
6
+ "Link": "Visual",
14
7
  "Loading": "Visual",
15
8
  "MultiRoute": "Visual",
16
9
  "Navbar": "Visual",
17
10
  "NotFound": "Visual",
18
11
  "Route": "Visual",
19
- "Link": "Visual",
20
- "Select": "Visual",
21
- "Switch": "Visual",
22
- "TreeItem": "Visual",
23
- "TreeView": "Visual",
24
12
  "FetchManager": "Service",
25
13
  "IndexedDbManager": "Service",
26
14
  "LocalStorageManager": "Service"
package/src/routes.js CHANGED
@@ -1,16 +1,10 @@
1
+ // App Shell + MultiRoute starter.
2
+ // Every section URL renders AppShell, which swaps the content area via a MultiRoute.
3
+ // Dynamic params use ${name} (NOT :name). Keep the 404 route last.
1
4
  const routes = [
2
- // Rutas principales
3
- { path: '/', component: 'HomePage' },
4
- { path: '/404', component: 'NotFound' },
5
- {
6
- path: '/Docum/${category}/${id}',
7
- component: 'LandingPage',
8
- },
9
- {
10
- path: "/Playground",
11
- component: "Playground",
12
- }
13
-
5
+ { path: '/', component: 'AppShell', metadata: { title: 'Home' } },
6
+ { path: '/about', component: 'AppShell', metadata: { title: 'About' } },
7
+ { path: '/404', component: 'NotFound', metadata: { title: 'Not Found' } }
14
8
  ];
15
9
 
16
10
  export default routes;
@@ -68,6 +68,7 @@
68
68
  "publicFolders": [
69
69
  "/Themes",
70
70
  "/Styles",
71
- "/assets"
71
+ "/assets",
72
+ "/images"
72
73
  ]
73
74
  }