@quincarter/create-lit-app 1.1.3 → 1.1.5
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/create-app-shell.sh +76 -17
- package/package.json +1 -1
package/create-app-shell.sh
CHANGED
|
@@ -867,7 +867,7 @@ if [ "$ENABLE_ROUTER" = true ]; then
|
|
|
867
867
|
directory: \"todos-page\",
|
|
868
868
|
component: \"todos-page\",
|
|
869
869
|
filePath: \"../../views/todos-page/todos-page.ts\",
|
|
870
|
-
levelOfAccess: [\"
|
|
870
|
+
levelOfAccess: [\"private\"],
|
|
871
871
|
tagName: \"todos-page\",
|
|
872
872
|
isMfe: false,
|
|
873
873
|
}"
|
|
@@ -953,6 +953,11 @@ export const routesBuilt = (
|
|
|
953
953
|
icon: navItem.icon || ("" as IconType),
|
|
954
954
|
mfeComponent: getMfeComponent(navItem.tagName),
|
|
955
955
|
userHasPermission: getAccessPermissions(navItem, accesses),
|
|
956
|
+
children: navItem.children?.map((child: NavItem) => ({
|
|
957
|
+
...child,
|
|
958
|
+
icon: child.icon || ("" as IconType),
|
|
959
|
+
userHasPermission: getAccessPermissions(child, accesses),
|
|
960
|
+
})),
|
|
956
961
|
}));
|
|
957
962
|
};
|
|
958
963
|
EOF
|
|
@@ -1262,10 +1267,12 @@ export class AppShellHeader extends LitElement {
|
|
|
1262
1267
|
${
|
|
1263
1268
|
this.routes.length > 0
|
|
1264
1269
|
? html`<ul>
|
|
1265
|
-
${this.routes
|
|
1266
|
-
(route) =>
|
|
1267
|
-
|
|
1268
|
-
|
|
1270
|
+
${this.routes
|
|
1271
|
+
.filter((route) => route.userHasPermission !== false)
|
|
1272
|
+
.map(
|
|
1273
|
+
(route) =>
|
|
1274
|
+
html`<li><a href="${withBase(route.path)}">${route.name}</a></li>`,
|
|
1275
|
+
)}
|
|
1269
1276
|
</ul>`
|
|
1270
1277
|
: nothing
|
|
1271
1278
|
}
|
|
@@ -1607,7 +1614,6 @@ export const ViewMixin = <T extends Constructor<LitElement>>(superClass: T) => {
|
|
|
1607
1614
|
|
|
1608
1615
|
connectedCallback(): void {
|
|
1609
1616
|
super.connectedCallback();
|
|
1610
|
-
this.featureIsEnabled = true;
|
|
1611
1617
|
this.mfeLoader?.init();
|
|
1612
1618
|
}
|
|
1613
1619
|
|
|
@@ -1624,7 +1630,7 @@ export const ViewMixin = <T extends Constructor<LitElement>>(superClass: T) => {
|
|
|
1624
1630
|
return this.renderUnderConstruction();
|
|
1625
1631
|
}
|
|
1626
1632
|
|
|
1627
|
-
if (customTemplate) return html`${customTemplate}`;
|
|
1633
|
+
if (customTemplate && this.featureIsEnabled) return html`${customTemplate}`;
|
|
1628
1634
|
|
|
1629
1635
|
return html`${
|
|
1630
1636
|
this.featureIsEnabled && this.isMfe
|
|
@@ -1793,13 +1799,23 @@ EOF
|
|
|
1793
1799
|
IMPORTS="import { type HTMLTemplateResult, html, LitElement } from 'lit';
|
|
1794
1800
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
1795
1801
|
import { AppShellStyles } from './app-shell.styles';
|
|
1796
|
-
import type { NavItem } from './shared/interfaces/navigation.interface';
|
|
1802
|
+
import type { NavItem } from './shared/interfaces/navigation.interface';
|
|
1803
|
+
import \"./shared/internal-views/404-not-found/page-not-found\";
|
|
1804
|
+
import \"./shared/internal-views/no-access/no-access\";
|
|
1805
|
+
import \"./shared/internal-views/under-construction/under-construction\";"
|
|
1797
1806
|
|
|
1798
1807
|
if [ "$ENABLE_CONTEXT" = true ]; then
|
|
1799
1808
|
IMPORTS="$IMPORTS
|
|
1800
1809
|
import { provide } from '@lit/context';
|
|
1801
1810
|
import { AccessesContext } from './shared/contexts/accesses.context';
|
|
1802
|
-
import { NavigationContext } from './shared/contexts/navigation.context';
|
|
1811
|
+
import { NavigationContext } from './shared/contexts/navigation.context';"
|
|
1812
|
+
fi
|
|
1813
|
+
|
|
1814
|
+
# MFE loader context is provided independently of ENABLE_CONTEXT so the
|
|
1815
|
+
# micro-frontend (MFE) utility works even when context features are off.
|
|
1816
|
+
if [ "$ENABLE_MFE_LOADER" = true ]; then
|
|
1817
|
+
IMPORTS="$IMPORTS
|
|
1818
|
+
import { provide } from '@lit/context';
|
|
1803
1819
|
import { MfeLoaderContext } from './shared/contexts/mfe-loader.context';"
|
|
1804
1820
|
fi
|
|
1805
1821
|
|
|
@@ -1808,9 +1824,10 @@ if [ "$ENABLE_ROUTER" = true ]; then
|
|
|
1808
1824
|
import { Router } from '@lit-labs/router';
|
|
1809
1825
|
import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
|
|
1810
1826
|
import 'urlpattern-polyfill';
|
|
1811
|
-
import { navigationRouting } from './shared/configuration/nav';
|
|
1827
|
+
import { navigationRouting, sidePages } from './shared/configuration/nav';
|
|
1812
1828
|
import { routesBuilt } from './shared/configuration/routes';
|
|
1813
|
-
import { withBase } from './shared/configuration/base-path';
|
|
1829
|
+
import { withBase } from './shared/configuration/base-path';
|
|
1830
|
+
import { AppRootUtilities } from './shared/utilities/app-root.utility';"
|
|
1814
1831
|
fi
|
|
1815
1832
|
|
|
1816
1833
|
if [ "$ENABLE_HEADER" = true ]; then
|
|
@@ -1841,13 +1858,34 @@ cat <<EOF >> src/app-shell.ts
|
|
|
1841
1858
|
@property({ type: Array })
|
|
1842
1859
|
accesses: string[] = ["public"];
|
|
1843
1860
|
EOF
|
|
1844
|
-
|
|
1861
|
+
else
|
|
1862
|
+
cat <<EOF >> src/app-shell.ts
|
|
1863
|
+
@property({ type: Array })
|
|
1864
|
+
routing: NavItem[] = [];
|
|
1865
|
+
|
|
1866
|
+
@property({ type: Array })
|
|
1867
|
+
accesses: string[] = ["public"];
|
|
1868
|
+
EOF
|
|
1869
|
+
fi
|
|
1870
|
+
|
|
1871
|
+
if [ "$ENABLE_ROUTER" = true ]; then
|
|
1872
|
+
cat <<EOF >> src/app-shell.ts
|
|
1873
|
+
@state()
|
|
1874
|
+
navRoutes: NavItem[] = [] as NavItem[];
|
|
1875
|
+
|
|
1876
|
+
@state()
|
|
1877
|
+
notAllowedRouteList: NavItem[] = [];
|
|
1878
|
+
EOF
|
|
1879
|
+
fi
|
|
1880
|
+
|
|
1881
|
+
# Provide the MFE loader independently of ENABLE_CONTEXT so that the MFE
|
|
1882
|
+
# utility initializes even when context features are disabled.
|
|
1883
|
+
if [ "$ENABLE_MFE_LOADER" = true ]; then
|
|
1845
1884
|
cat <<EOF >> src/app-shell.ts
|
|
1846
1885
|
@provide({ context: MfeLoaderContext })
|
|
1847
1886
|
@state()
|
|
1848
1887
|
mfeLoader = new MfeLoader(MFE_LOADER_CONFIG);
|
|
1849
1888
|
EOF
|
|
1850
|
-
fi
|
|
1851
1889
|
fi
|
|
1852
1890
|
|
|
1853
1891
|
if [ "$ENABLE_ROUTER" = true ]; then
|
|
@@ -1866,10 +1904,19 @@ EOF
|
|
|
1866
1904
|
|
|
1867
1905
|
if [ "$ENABLE_ROUTER" = true ]; then
|
|
1868
1906
|
cat <<EOF >> src/app-shell.ts
|
|
1907
|
+
this.navRoutes = this._buildNavBarRoutes(navigationRouting);
|
|
1869
1908
|
await this._setupRoutes();
|
|
1870
1909
|
EOF
|
|
1871
1910
|
fi
|
|
1872
1911
|
|
|
1912
|
+
# Initialize the MFE loader at the shell level (independent of ENABLE_CONTEXT)
|
|
1913
|
+
# so micro-frontend bundles are injected regardless of context feature state.
|
|
1914
|
+
if [ "$ENABLE_MFE_LOADER" = true ]; then
|
|
1915
|
+
cat <<EOF >> src/app-shell.ts
|
|
1916
|
+
await this.mfeLoader?.init();
|
|
1917
|
+
EOF
|
|
1918
|
+
fi
|
|
1919
|
+
|
|
1873
1920
|
cat <<EOF >> src/app-shell.ts
|
|
1874
1921
|
}
|
|
1875
1922
|
EOF
|
|
@@ -1877,8 +1924,20 @@ EOF
|
|
|
1877
1924
|
if [ "$ENABLE_ROUTER" = true ]; then
|
|
1878
1925
|
cat <<EOF >> src/app-shell.ts
|
|
1879
1926
|
|
|
1927
|
+
private _buildNavBarRoutes(navItems: NavItem[]): NavItem[] {
|
|
1928
|
+
const navi = routesBuilt(navItems, this.accesses);
|
|
1929
|
+
const { notAllowed, navItems: filtered } =
|
|
1930
|
+
AppRootUtilities.getNotAllowedRoutes(navi, this.notAllowedRouteList);
|
|
1931
|
+
this.notAllowedRouteList = notAllowed;
|
|
1932
|
+
return filtered;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1880
1935
|
private async _setupRoutes(): Promise<void> {
|
|
1881
|
-
|
|
1936
|
+
const detailRoutes = this._buildNavBarRoutes([...sidePages]);
|
|
1937
|
+
this.routing = routesBuilt(
|
|
1938
|
+
[...this.navRoutes, ...this.notAllowedRouteList, ...detailRoutes],
|
|
1939
|
+
this.accesses,
|
|
1940
|
+
);
|
|
1882
1941
|
const routeConfigs = this.routing.map((navItem) => ({
|
|
1883
1942
|
path: withBase(navItem.path),
|
|
1884
1943
|
enter: async () => {
|
|
@@ -1891,8 +1950,8 @@ cat <<EOF >> src/app-shell.ts
|
|
|
1891
1950
|
},
|
|
1892
1951
|
}));
|
|
1893
1952
|
|
|
1894
|
-
const firstPath =
|
|
1895
|
-
const firstItem =
|
|
1953
|
+
const firstPath = this.navRoutes[0]?.path || "/home";
|
|
1954
|
+
const firstItem = this.navRoutes[0];
|
|
1896
1955
|
|
|
1897
1956
|
this._router.routes = [
|
|
1898
1957
|
{
|
|
@@ -1926,7 +1985,7 @@ EOF
|
|
|
1926
1985
|
|
|
1927
1986
|
if [ "$ENABLE_HEADER" = true ]; then
|
|
1928
1987
|
cat <<EOF >> src/app-shell.ts
|
|
1929
|
-
<app-shell-header .routes="\${this.
|
|
1988
|
+
<app-shell-header .routes="\${this.navRoutes}" enable-theme-switcher>
|
|
1930
1989
|
<main>
|
|
1931
1990
|
EOF
|
|
1932
1991
|
else
|