slicejs-web-framework 4.0.0 → 4.0.1
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 -14
- package/LICENSE +21 -21
- package/README.md +97 -97
- package/Slice/Components/Structural/ContextManager/ContextManager.js +422 -422
- package/Slice/Components/Structural/ContextManager/ContextManagerDebugger.js +470 -470
- package/Slice/Components/Structural/Controller/Controller.js +1406 -1406
- package/Slice/Components/Structural/Controller/allowedValuesValidation.js +52 -52
- package/Slice/Components/Structural/Debugger/Debugger.html +72 -72
- package/Slice/Components/Structural/Debugger/Debugger.js +1505 -1505
- package/Slice/Components/Structural/EventManager/EventManager.js +651 -651
- package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +985 -985
- package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -296
- package/Slice/Components/Structural/Logger/Log.js +10 -10
- package/Slice/Components/Structural/Logger/LogViewer/LogViewer.js +662 -662
- package/Slice/Components/Structural/Logger/Logger.js +225 -225
- package/Slice/Components/Structural/Router/Router.js +793 -793
- package/Slice/Components/Structural/StylesManager/StylesManager.js +82 -82
- package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +162 -162
- package/Slice/Slice.js +686 -697
- package/Slice/tests/build-bundled-component-without-category.test.js +103 -103
- package/Slice/tests/build-js-only-visual-components.test.js +144 -144
- package/Slice/tests/build-singleton.test.js +244 -244
- package/Slice/tests/bundle-v2-runtime-contract.test.js +738 -738
- package/Slice/tests/context-patch-use.test.js +95 -95
- package/Slice/tests/destroy-cascade.test.js +215 -215
- package/Slice/tests/event-emitters.test.js +79 -79
- package/Slice/tests/event-registry.test.js +141 -141
- package/Slice/tests/fixtures/real-runtime-loader.mjs +21 -21
- package/Slice/tests/leak-orphans.test.js +131 -131
- package/Slice/tests/props-allowed-values-validation.test.js +119 -119
- package/Slice/tests/public-env-runtime-accessors.test.js +44 -44
- package/Slice/tests/public-env-typed-accessors.test.js +66 -66
- package/Slice/tests/router-loading-finally.test.js +68 -68
- package/api/framework/devDepsOptimizer.js +335 -335
- package/api/framework/express.js +3 -3
- package/api/framework/precompressedStatic.js +93 -93
- package/api/framework/publicEnvResolver.js +123 -123
- package/api/framework/securityMiddleware.js +197 -197
- package/api/framework/server.js +411 -411
- package/api/index.js +7 -7
- package/api/tests/dev-deps-optimizer.test.js +137 -137
- package/api/tests/dev-server-external.test.js +56 -56
- package/api/tests/precompressed-static.test.js +119 -119
- package/api/tests/public-env-resolver.test.js +193 -193
- package/package.json +49 -49
- package/sliceConfig.schema.json +122 -122
- package/src/App/index.html +69 -69
- package/src/App/index.js +20 -20
- package/src/App/style.css +11 -11
- package/src/Components/AppComponents/AboutSection/AboutSection.css +9 -9
- package/src/Components/AppComponents/AboutSection/AboutSection.html +8 -8
- package/src/Components/AppComponents/AboutSection/AboutSection.js +12 -12
- package/src/Components/AppComponents/AppShell/AppShell.css +10 -10
- package/src/Components/AppComponents/AppShell/AppShell.html +4 -4
- package/src/Components/AppComponents/AppShell/AppShell.js +36 -36
- package/src/Components/AppComponents/HomeSection/HomeSection.css +20 -20
- package/src/Components/AppComponents/HomeSection/HomeSection.html +10 -10
- package/src/Components/AppComponents/HomeSection/HomeSection.js +19 -19
- package/src/Components/components.js +8 -8
- package/src/public/Styles/sliceStyles.css +34 -34
- package/src/public/Themes/Dark.css +42 -42
- package/src/public/Themes/Light.css +31 -31
- package/src/public/Themes/Slice.css +47 -47
- package/src/public/manifest.json +15 -15
- package/src/public/robots.txt +4 -4
- package/src/public/sitemap.xml +8 -8
- package/src/routes.js +9 -9
- package/src/sliceConfig.json +72 -72
- package/tests/router-emit-ordering.test.js +63 -63
- package/types/index.d.ts +219 -219
package/sliceConfig.schema.json
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://slicejs.local/sliceConfig.schema.json",
|
|
4
|
-
"title": "Slice.js Config",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": true,
|
|
7
|
-
"properties": {
|
|
8
|
-
"debugger": {
|
|
9
|
-
"type": "object",
|
|
10
|
-
"additionalProperties": true,
|
|
11
|
-
"properties": {
|
|
12
|
-
"enabled": { "type": "boolean" },
|
|
13
|
-
"click": { "type": "string", "enum": ["right", "left"] },
|
|
14
|
-
"leakInspector": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"additionalProperties": true,
|
|
17
|
-
"description": "Dev-only memory-leak panel. Disabled in production regardless of this flag.",
|
|
18
|
-
"properties": {
|
|
19
|
-
"enabled": { "type": "boolean" },
|
|
20
|
-
"shortcut": { "type": "string" }
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"stylesManager": {
|
|
26
|
-
"type": "object",
|
|
27
|
-
"additionalProperties": true,
|
|
28
|
-
"properties": {
|
|
29
|
-
"requestedStyles": { "type": "array", "items": { "type": "string" } }
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"themeManager": {
|
|
33
|
-
"type": "object",
|
|
34
|
-
"additionalProperties": true,
|
|
35
|
-
"properties": {
|
|
36
|
-
"enabled": { "type": "boolean" },
|
|
37
|
-
"defaultTheme": { "type": "string" },
|
|
38
|
-
"saveThemeLocally": { "type": "boolean" },
|
|
39
|
-
"useBrowserTheme": { "type": "boolean" }
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"logger": {
|
|
43
|
-
"type": "object",
|
|
44
|
-
"additionalProperties": true,
|
|
45
|
-
"properties": {
|
|
46
|
-
"enabled": { "type": "boolean" },
|
|
47
|
-
"showLogs": { "type": "object", "additionalProperties": true },
|
|
48
|
-
"ui": {
|
|
49
|
-
"type": "object",
|
|
50
|
-
"additionalProperties": true,
|
|
51
|
-
"properties": {
|
|
52
|
-
"enabled": { "type": "boolean" },
|
|
53
|
-
"shortcut": { "type": "string" }
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"events": {
|
|
59
|
-
"type": "object",
|
|
60
|
-
"additionalProperties": true,
|
|
61
|
-
"properties": {
|
|
62
|
-
"enabled": { "type": "boolean" },
|
|
63
|
-
"ui": {
|
|
64
|
-
"type": "object",
|
|
65
|
-
"additionalProperties": true,
|
|
66
|
-
"properties": {
|
|
67
|
-
"enabled": { "type": "boolean" },
|
|
68
|
-
"shortcut": { "type": "string" }
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
"context": {
|
|
74
|
-
"type": "object",
|
|
75
|
-
"additionalProperties": true,
|
|
76
|
-
"properties": {
|
|
77
|
-
"enabled": { "type": "boolean" },
|
|
78
|
-
"ui": {
|
|
79
|
-
"type": "object",
|
|
80
|
-
"additionalProperties": true,
|
|
81
|
-
"properties": {
|
|
82
|
-
"enabled": { "type": "boolean" },
|
|
83
|
-
"shortcut": { "type": "string" }
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
"paths": {
|
|
89
|
-
"type": "object",
|
|
90
|
-
"additionalProperties": true,
|
|
91
|
-
"properties": {
|
|
92
|
-
"components": { "type": "object", "additionalProperties": true },
|
|
93
|
-
"themes": { "type": "string" },
|
|
94
|
-
"styles": { "type": "string" },
|
|
95
|
-
"routesFile": { "type": "string" }
|
|
96
|
-
},
|
|
97
|
-
"required": ["components", "themes", "styles", "routesFile"]
|
|
98
|
-
},
|
|
99
|
-
"router": {
|
|
100
|
-
"type": "object",
|
|
101
|
-
"additionalProperties": true,
|
|
102
|
-
"properties": {
|
|
103
|
-
"defaultRoute": { "type": "string" }
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"loading": {
|
|
107
|
-
"type": "object",
|
|
108
|
-
"additionalProperties": true,
|
|
109
|
-
"properties": {
|
|
110
|
-
"enabled": { "type": "boolean" }
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
"server": {
|
|
114
|
-
"type": "object",
|
|
115
|
-
"additionalProperties": true,
|
|
116
|
-
"properties": {
|
|
117
|
-
"port": { "type": "number" },
|
|
118
|
-
"host": { "type": "string" }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://slicejs.local/sliceConfig.schema.json",
|
|
4
|
+
"title": "Slice.js Config",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": true,
|
|
7
|
+
"properties": {
|
|
8
|
+
"debugger": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"additionalProperties": true,
|
|
11
|
+
"properties": {
|
|
12
|
+
"enabled": { "type": "boolean" },
|
|
13
|
+
"click": { "type": "string", "enum": ["right", "left"] },
|
|
14
|
+
"leakInspector": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": true,
|
|
17
|
+
"description": "Dev-only memory-leak panel. Disabled in production regardless of this flag.",
|
|
18
|
+
"properties": {
|
|
19
|
+
"enabled": { "type": "boolean" },
|
|
20
|
+
"shortcut": { "type": "string" }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"stylesManager": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"additionalProperties": true,
|
|
28
|
+
"properties": {
|
|
29
|
+
"requestedStyles": { "type": "array", "items": { "type": "string" } }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"themeManager": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": true,
|
|
35
|
+
"properties": {
|
|
36
|
+
"enabled": { "type": "boolean" },
|
|
37
|
+
"defaultTheme": { "type": "string" },
|
|
38
|
+
"saveThemeLocally": { "type": "boolean" },
|
|
39
|
+
"useBrowserTheme": { "type": "boolean" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"logger": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"additionalProperties": true,
|
|
45
|
+
"properties": {
|
|
46
|
+
"enabled": { "type": "boolean" },
|
|
47
|
+
"showLogs": { "type": "object", "additionalProperties": true },
|
|
48
|
+
"ui": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": true,
|
|
51
|
+
"properties": {
|
|
52
|
+
"enabled": { "type": "boolean" },
|
|
53
|
+
"shortcut": { "type": "string" }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"events": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"additionalProperties": true,
|
|
61
|
+
"properties": {
|
|
62
|
+
"enabled": { "type": "boolean" },
|
|
63
|
+
"ui": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"additionalProperties": true,
|
|
66
|
+
"properties": {
|
|
67
|
+
"enabled": { "type": "boolean" },
|
|
68
|
+
"shortcut": { "type": "string" }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"context": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"additionalProperties": true,
|
|
76
|
+
"properties": {
|
|
77
|
+
"enabled": { "type": "boolean" },
|
|
78
|
+
"ui": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"additionalProperties": true,
|
|
81
|
+
"properties": {
|
|
82
|
+
"enabled": { "type": "boolean" },
|
|
83
|
+
"shortcut": { "type": "string" }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"paths": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"additionalProperties": true,
|
|
91
|
+
"properties": {
|
|
92
|
+
"components": { "type": "object", "additionalProperties": true },
|
|
93
|
+
"themes": { "type": "string" },
|
|
94
|
+
"styles": { "type": "string" },
|
|
95
|
+
"routesFile": { "type": "string" }
|
|
96
|
+
},
|
|
97
|
+
"required": ["components", "themes", "styles", "routesFile"]
|
|
98
|
+
},
|
|
99
|
+
"router": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"additionalProperties": true,
|
|
102
|
+
"properties": {
|
|
103
|
+
"defaultRoute": { "type": "string" }
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"loading": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": true,
|
|
109
|
+
"properties": {
|
|
110
|
+
"enabled": { "type": "boolean" }
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"server": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"additionalProperties": true,
|
|
116
|
+
"properties": {
|
|
117
|
+
"port": { "type": "number" },
|
|
118
|
+
"host": { "type": "string" }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/App/index.html
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Slice.js Web Framework</title>
|
|
7
|
-
<meta name="description" content="Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time. No build step required." />
|
|
8
|
-
<meta name="robots" content="index, follow" />
|
|
9
|
-
<meta name="author" content="vkneider.dev" />
|
|
10
|
-
<link rel="canonical" href="https://slicejs.com" />
|
|
11
|
-
<link rel="icon" type="image/x-icon" href="/images/favicon.ico" />
|
|
12
|
-
<link rel="apple-touch-icon" href="/images/og-image.png" />
|
|
13
|
-
<link rel="manifest" href="/manifest.json" />
|
|
14
|
-
<meta name="theme-color" content="#F8F4FF" />
|
|
15
|
-
<meta name="color-scheme" content="light dark" />
|
|
16
|
-
<meta property="og:type" content="website" />
|
|
17
|
-
<meta property="og:title" content="Slice.js Web Framework" />
|
|
18
|
-
<meta property="og:description" content="Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time. No build step required." />
|
|
19
|
-
<meta property="og:url" content="https://slicejs.com" />
|
|
20
|
-
<meta property="og:image" content="https://slicejs.com/images/og-image.png" />
|
|
21
|
-
<meta name="twitter:card" content="summary_large_image" />
|
|
22
|
-
<meta name="twitter:title" content="Slice.js Web Framework" />
|
|
23
|
-
<meta name="twitter:description" content="Slice.js — a lightweight web framework built on native Web Components." />
|
|
24
|
-
<meta name="twitter:image" content="https://slicejs.com/images/og-image.png" />
|
|
25
|
-
<link rel="stylesheet" type="text/css" href="/App/style.css" />
|
|
26
|
-
<script type="application/ld+json">
|
|
27
|
-
{
|
|
28
|
-
"@context": "https://schema.org",
|
|
29
|
-
"@type": "WebSite",
|
|
30
|
-
"name": "Slice.js Web Framework",
|
|
31
|
-
"url": "https://slicejs.com",
|
|
32
|
-
"description": "Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time.",
|
|
33
|
-
"author": {
|
|
34
|
-
"@type": "Organization",
|
|
35
|
-
"name": "VKneider",
|
|
36
|
-
"url": "https://github.com/VKneider"
|
|
37
|
-
},
|
|
38
|
-
"potentialAction": {
|
|
39
|
-
"@type": "SearchAction",
|
|
40
|
-
"target": {
|
|
41
|
-
"@type": "EntryPoint",
|
|
42
|
-
"urlTemplate": "https://slicejs.com/?q={search_term_string}"
|
|
43
|
-
},
|
|
44
|
-
"query-input": "required name=search_term_string"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
<script type="application/ld+json">
|
|
49
|
-
{
|
|
50
|
-
"@context": "https://schema.org",
|
|
51
|
-
"@type": "BreadcrumbList",
|
|
52
|
-
"itemListElement": [
|
|
53
|
-
{
|
|
54
|
-
"@type": "ListItem",
|
|
55
|
-
"position": 1,
|
|
56
|
-
"name": "Home",
|
|
57
|
-
"item": "https://slicejs.com/"
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
</script>
|
|
62
|
-
</head>
|
|
63
|
-
|
|
64
|
-
<body>
|
|
65
|
-
<div id="app">
|
|
66
|
-
<script src="/App/index.js" type="module"></script>
|
|
67
|
-
</div>
|
|
68
|
-
</body>
|
|
69
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Slice.js Web Framework</title>
|
|
7
|
+
<meta name="description" content="Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time. No build step required." />
|
|
8
|
+
<meta name="robots" content="index, follow" />
|
|
9
|
+
<meta name="author" content="vkneider.dev" />
|
|
10
|
+
<link rel="canonical" href="https://slicejs.com" />
|
|
11
|
+
<link rel="icon" type="image/x-icon" href="/images/favicon.ico" />
|
|
12
|
+
<link rel="apple-touch-icon" href="/images/og-image.png" />
|
|
13
|
+
<link rel="manifest" href="/manifest.json" />
|
|
14
|
+
<meta name="theme-color" content="#F8F4FF" />
|
|
15
|
+
<meta name="color-scheme" content="light dark" />
|
|
16
|
+
<meta property="og:type" content="website" />
|
|
17
|
+
<meta property="og:title" content="Slice.js Web Framework" />
|
|
18
|
+
<meta property="og:description" content="Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time. No build step required." />
|
|
19
|
+
<meta property="og:url" content="https://slicejs.com" />
|
|
20
|
+
<meta property="og:image" content="https://slicejs.com/images/og-image.png" />
|
|
21
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
22
|
+
<meta name="twitter:title" content="Slice.js Web Framework" />
|
|
23
|
+
<meta name="twitter:description" content="Slice.js — a lightweight web framework built on native Web Components." />
|
|
24
|
+
<meta name="twitter:image" content="https://slicejs.com/images/og-image.png" />
|
|
25
|
+
<link rel="stylesheet" type="text/css" href="/App/style.css" />
|
|
26
|
+
<script type="application/ld+json">
|
|
27
|
+
{
|
|
28
|
+
"@context": "https://schema.org",
|
|
29
|
+
"@type": "WebSite",
|
|
30
|
+
"name": "Slice.js Web Framework",
|
|
31
|
+
"url": "https://slicejs.com",
|
|
32
|
+
"description": "Slice.js — a lightweight web framework built on native Web Components. Build web apps one slice at a time.",
|
|
33
|
+
"author": {
|
|
34
|
+
"@type": "Organization",
|
|
35
|
+
"name": "VKneider",
|
|
36
|
+
"url": "https://github.com/VKneider"
|
|
37
|
+
},
|
|
38
|
+
"potentialAction": {
|
|
39
|
+
"@type": "SearchAction",
|
|
40
|
+
"target": {
|
|
41
|
+
"@type": "EntryPoint",
|
|
42
|
+
"urlTemplate": "https://slicejs.com/?q={search_term_string}"
|
|
43
|
+
},
|
|
44
|
+
"query-input": "required name=search_term_string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
<script type="application/ld+json">
|
|
49
|
+
{
|
|
50
|
+
"@context": "https://schema.org",
|
|
51
|
+
"@type": "BreadcrumbList",
|
|
52
|
+
"itemListElement": [
|
|
53
|
+
{
|
|
54
|
+
"@type": "ListItem",
|
|
55
|
+
"position": 1,
|
|
56
|
+
"name": "Home",
|
|
57
|
+
"item": "https://slicejs.com/"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
</head>
|
|
63
|
+
|
|
64
|
+
<body>
|
|
65
|
+
<div id="app">
|
|
66
|
+
<script src="/App/index.js" type="module"></script>
|
|
67
|
+
</div>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
package/src/App/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import Slice from '/Slice/Slice.js';
|
|
2
|
-
|
|
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();
|
|
1
|
+
import Slice from '/Slice/Slice.js';
|
|
2
|
+
|
|
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,11 +1,11 @@
|
|
|
1
|
-
/* App-level base styles. Component styles live in each component's own .css. */
|
|
2
|
-
* {
|
|
3
|
-
box-sizing: border-box;
|
|
4
|
-
font-family: var(--font-family, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
body {
|
|
8
|
-
margin: 0;
|
|
9
|
-
background: var(--primary-background-color);
|
|
10
|
-
color: var(--font-primary-color);
|
|
11
|
-
}
|
|
1
|
+
/* App-level base styles. Component styles live in each component's own .css. */
|
|
2
|
+
* {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
font-family: var(--font-family, system-ui, -apple-system, Segoe UI, Roboto, sans-serif);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
background: var(--primary-background-color);
|
|
10
|
+
color: var(--font-primary-color);
|
|
11
|
+
}
|
|
@@ -1,9 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,8 +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>
|
|
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>
|
|
@@ -1,12 +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);
|
|
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);
|
|
@@ -1,10 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="app-shell">
|
|
2
|
-
<header class="app-shell__header"></header>
|
|
3
|
-
<main class="app-shell__content"></main>
|
|
4
|
-
</div>
|
|
1
|
+
<div class="app-shell">
|
|
2
|
+
<header class="app-shell__header"></header>
|
|
3
|
+
<main class="app-shell__content"></main>
|
|
4
|
+
</div>
|
|
@@ -1,36 +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);
|
|
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);
|