Consolidate Lit repositories: figma-to-lit, figma_lit_example, lit-3d-piano, lit-calculator, lit-code-editor, lit-draggable-dom, lit-file-based-routing, lit-force-graph, lit-html-editor, lit-html-table, lit-modules, lit-native, lit-node-editor, lit-sheet-music, lit-starter-ts, lit-vscode-extension, lit-wmr, vite-lit-capacitor, vite-lit-element-starter, vite-rxdb-lit

This commit is contained in:
2026-05-16 22:17:12 -07:00
parent 4dc3c8a3ff
commit 95667e3038
527 changed files with 63872 additions and 54 deletions
+24
View File
@@ -0,0 +1,24 @@
name: Demo
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install
- run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
+5
View File
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
types
*.local
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+243
View File
@@ -0,0 +1,243 @@
[![Demo](https://github.com/rodydavis/lit-file-based-routing/actions/workflows/ci.yml/badge.svg)](https://github.com/rodydavis/lit-file-based-routing/actions/workflows/ci.yml)
# Lit File Based Routing
Lit router for nested layouts and file based routing. Similar to https://remix.run/ but at client side.
[Demo](https://rodydavis.github.io/lit-file-based-routing/#/dashboard/)
[Package](/lit-file-router/)
Archived in favor of: https://github.com/rodydavis/vscode-router-generator
## Features
- File based routing
- Nested layout
## Defining a root layout
To layout navigation once you will want to define a root layout that all pages can inherit from.
```js
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("root-module")
export class RootModule extends LitElement {
static styles = css`
main {
display: flex;
flex-direction: row;
height: 100vh;
width: 100%;
}
aside {
display: flex;
flex-direction: column;
background-color: whitesmoke;
padding: 8px;
}
section {
flex: 1;
}
`;
render() {
return html`
<main>
<aside>
<a href="#/">Home</a>
<a href="#/dashboard/">Dashboard</a>
<a href="#/settings/">Settings</a>
</aside>
<section><slot></slot></section>
</main>
`;
}
}
```
## Defining a base layout
You can define a base layout with the root name. For example: `dashboard.ts`
```ts
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("dashboard-module")
export class DashboardModule extends LitElement {
static styles = css`
header {
height: 40px;
background-color: orange;
color: white;
display: flex;
flex-direction: row;
align-items: center;
padding-left: 10px;
padding-right: 10px;
justify-content: space-between;
}
`;
render() {
return html`<main>
<header>
<span class="title">Dashboard</span>
<nav>
<a href="#/dashboard/overview">Overview</a>
<a href="#/dashboard/account/">Account</a>
</nav>
</header>
<section><slot></slot></section>
</main> `;
}
}
```
If you notice the `<slot>` is used for the nested layout.
## Defining the index route
You can define the index route for when there are no args needed. For example: `dashboard/index.ts`
```ts
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("dashboard-default")
export class DashboardDefault extends LitElement {
static styles = css``;
render() {
return html`<section>Default Dashboard</section>`;
}
}
```
Since this is a nested layout all you need to do is provide the component and it will inherit from the parent layout (dashboard.ts).
## Defining a named arg
You can define a named arg for a route if there is something that does not need data fetched for. For example: `/dashboard/overview.ts`
```ts
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("overview-module")
export class OverviewModule extends LitElement {
static styles = css``;
render() {
return html`<section>Overview</section>`;
}
}
```
This is also just a component.
## Defining a dynamic arg
Sometimes the arg is generated at runtime or needs to be pulled from a database. For example: `dashboard/account/:id.ts`
```ts
import { html, css, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
@customElement("account-details")
export class AccountDetails extends LitElement {
static styles = css``;
@property({ type: String }) id = "";
render() {
return html`<section>User ID: ${this.id}</section>`;
}
}
```
You can see we set the file name with a prefix of `:` to define an arg to look for and match against. This will be provided in a map.
## Usage
If you install the package locally you can run `node lit-file-router` to have `src/generated-app.ts` added as a file when it analyzes the `src/pages/` directory.
```html
<body>
<generated-app> </generated-app>
<script type="module" src="/src/generated-app.ts"></script>
</body>
```
### Dynamic Imports
You can have the components load async with dynamic imports using the following command:
`node lit-file-router --dynamic-imports=true`
By default it will use static imports and have everything loaded at runtime.
### Data caching and loader function
You can export a loader function that will be used to set data on the component:
```js
import { html, css, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
export async function loader(
route: string,
args: { [key: string]: any }
): Promise<AccountData> {
await new Promise((resolve) => setTimeout(resolve, 1000));
const id = args["id"]!;
return {
id,
name: "Name: " + id,
email: route,
};
}
@customElement("account-details")
export class AccountDetails extends LitElement {
static styles = css``;
@property({ type: String }) id = "";
@property({ type: Object }) data!: AccountData;
render() {
return html`<section>User ID: ${this.data.id}</section>`;
}
}
interface AccountData {
id: string;
name: string;
email: string;
}
```
This will call the function to load the data before rendering starts.
If you want to enable caching you can add the following command:
`node lit-file-router --cache-all`
It is off by default but it will cache the data from the loader function for the component and route and will pass the cached data from memory to the component.
## Loading state
You can pass show a progress indicator at the bottom by passing a loading arg:
`node lit-file-router --show-loading=true`
It is off by default, but this is useful for heavy requests that would hang the UI.
+19
View File
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Lit App</title>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<generated-app> </generated-app>
<script type="module" src="/src/generated-app.ts"></script>
</body>
</html>
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
types
*.local
+269
View File
@@ -0,0 +1,269 @@
{
"name": "lit-file-router",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"dev": true
},
"esbuild": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
"dev": true,
"requires": {
"esbuild-android-arm64": "0.13.15",
"esbuild-darwin-64": "0.13.15",
"esbuild-darwin-arm64": "0.13.15",
"esbuild-freebsd-64": "0.13.15",
"esbuild-freebsd-arm64": "0.13.15",
"esbuild-linux-32": "0.13.15",
"esbuild-linux-64": "0.13.15",
"esbuild-linux-arm": "0.13.15",
"esbuild-linux-arm64": "0.13.15",
"esbuild-linux-mips64le": "0.13.15",
"esbuild-linux-ppc64le": "0.13.15",
"esbuild-netbsd-64": "0.13.15",
"esbuild-openbsd-64": "0.13.15",
"esbuild-sunos-64": "0.13.15",
"esbuild-windows-32": "0.13.15",
"esbuild-windows-64": "0.13.15",
"esbuild-windows-arm64": "0.13.15"
}
},
"esbuild-android-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
"dev": true,
"optional": true
},
"esbuild-darwin-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
"dev": true,
"optional": true
},
"esbuild-darwin-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
"dev": true,
"optional": true
},
"esbuild-freebsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
"dev": true,
"optional": true
},
"esbuild-freebsd-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
"dev": true,
"optional": true
},
"esbuild-linux-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
"dev": true,
"optional": true
},
"esbuild-linux-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
"dev": true,
"optional": true
},
"esbuild-linux-arm": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
"dev": true,
"optional": true
},
"esbuild-linux-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
"dev": true,
"optional": true
},
"esbuild-linux-mips64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
"dev": true,
"optional": true
},
"esbuild-linux-ppc64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
"dev": true,
"optional": true
},
"esbuild-netbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
"dev": true,
"optional": true
},
"esbuild-openbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
"dev": true,
"optional": true
},
"esbuild-sunos-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
"dev": true,
"optional": true
},
"esbuild-windows-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
"dev": true,
"optional": true
},
"esbuild-windows-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
"dev": true,
"optional": true
},
"esbuild-windows-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
"dev": true,
"optional": true
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"is-core-module": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz",
"integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==",
"dev": true,
"requires": {
"has": "^1.0.3"
}
},
"nanoid": {
"version": "3.1.30",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==",
"dev": true
},
"path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"dev": true
},
"postcss": {
"version": "8.4.5",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.5.tgz",
"integrity": "sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==",
"dev": true,
"requires": {
"nanoid": "^3.1.30",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.1"
}
},
"resolve": {
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
"integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
"dev": true,
"requires": {
"is-core-module": "^2.8.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
}
},
"rollup": {
"version": "2.63.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.63.0.tgz",
"integrity": "sha512-nps0idjmD+NXl6OREfyYXMn/dar3WGcyKn+KBzPdaLecub3x/LrId0wUcthcr8oZUAcZAR8NKcfGGFlNgGL1kQ==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
}
},
"source-map-js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.1.tgz",
"integrity": "sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==",
"dev": true
},
"supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true
},
"typescript": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
"dev": true
},
"vite": {
"version": "2.7.10",
"resolved": "https://registry.npmjs.org/vite/-/vite-2.7.10.tgz",
"integrity": "sha512-KEY96ntXUid1/xJihJbgmLZx7QSC2D4Tui0FdS0Old5OokYzFclcofhtxtjDdGOk/fFpPbHv9yw88+rB93Tb8w==",
"dev": true,
"requires": {
"esbuild": "^0.13.12",
"fsevents": "~2.3.2",
"postcss": "^8.4.5",
"resolve": "^1.20.0",
"rollup": "^2.59.0"
}
}
}
}
@@ -0,0 +1,20 @@
{
"type": "module",
"name": "lit-file-router",
"version": "0.0.0",
"main": "dist/index.js",
"types": "types/index.d.ts",
"files": [
"dist",
"types"
],
"scripts": {
"preinstall": "npm run build",
"build": "tsc"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^17.0.8",
"typescript": "^4.4.4"
}
}
@@ -0,0 +1,56 @@
export function analyzePage(path: string, content: string): WebComponent[] {
const components: WebComponent[] = [];
// Check for export function loader( or export async function loader(
let hasLoader = false;
const lines = content.split("\n");
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (
line.includes("export function loader(") ||
line.includes("export async function loader(")
) {
hasLoader = true;
break;
}
}
// Look for @customElement decorator and get the value
const regex = /@customElement\("([^"]+)"\)/g;
const matches = content.match(regex);
if (matches) {
for (const match of matches) {
const result = match.match(/@customElement\("([^"]+)"\)/);
if (result) {
const name = result[1];
components.push({
name,
path,
hasLoader,
});
}
}
}
// Look for customElements.define() and get the value
const regex2 = /customElements\.define\("([^"]+)"/g;
const matches2 = content.match(regex2);
if (matches2) {
for (const match of matches2) {
const result = match.match(/customElements\.define\("([^"]+)"/);
if (result) {
const name = result[1];
components.push({
name,
path,
hasLoader,
});
}
}
}
return components;
}
export interface WebComponent {
name: string;
path: string;
alias?: string;
hasLoader: boolean;
}
@@ -0,0 +1,264 @@
import { WebComponent } from "./analyze-page";
import { StringBuilder } from "./string-builder";
export function generateApp(
sb: StringBuilder,
components: WebComponent[],
options: { staticImports: boolean; cacheAll: boolean; showLoading: boolean }
) {
sb.writeln(`import { html, css, LitElement } from "lit";`);
sb.writeln(
`import { customElement, property, state } from "lit/decorators.js";`
);
sb.writeln();
sb.writeAll([
'@customElement("generated-app")',
"export class GeneratedApp extends LitElement {",
" static styles = css`",
" main {",
" width: 100%;",
" height: 100%;",
" }",
...(options.showLoading
? [
" progress {",
" position: absolute;",
" bottom: 0;",
" width: calc(100% - 1rem);",
" z-index: 1;",
" left: 0.5rem;",
" right: 0.5rem;",
" }",
]
: []),
" `;",
"",
" @property() hash = 'true';",
" @property() base = '/';",
...(options.showLoading ? [" @state() loading = false;"] : []),
" @property() route = this.getCurrentRoute();",
" @state() child = document.createElement('main');",
"",
]);
if (options.cacheAll) {
sb.writeln(" dataCache = new Map<string, any>();");
}
sb.writeln(" components: Map<string, Route> = new Map([");
for (const component of components) {
let path = component.path.replace("./src/pages/", "/");
path = path.replace(".ts", "");
path = path.replace(".js", "");
path = path.replace("/index", "/");
// Check if path contains . and convert to /
if (path.indexOf(".") > -1) {
path = path.split(".").join("/");
}
if (path == "/root") path = "";
// sb.writeln(` ["${path}", "${component.name}"],`);]
sb.writeln(` ["${path}", {
component: "${component.name}",`);
const componentImportPath = component.path
.replace("./src/", "./")
.replace(".ts", ".js");
if (component.hasLoader) {
if (options.staticImports) {
sb.writeln(` loadData: async () => {
return ${component.alias}.loader;
},`);
} else {
sb.writeln(` loadData: async () => {
const {loader} = await import("${componentImportPath}");
return loader;
},`);
}
} else {
sb.writeln(` loadData: async () => null,`);
}
if (options.staticImports) {
sb.writeln(` loadImport: async () => ${component.alias},
}],`);
} else {
sb.writeln(` loadImport: () => import("${componentImportPath}"),
}],`);
}
}
sb.writeAll([
" ]);",
"",
" firstUpdated() {",
' window.addEventListener("hashchange", () => {',
" const oldRoute = this.route;",
" this.route = this.getCurrentRoute();",
" this.updateTree(oldRoute);",
" });",
" this.updateTree();",
" }",
"",
" render() {",
" return html` ${this.child} `;",
" }",
"",
" refresh() {",
" return this.updateTree();",
" }",
"",
" private async updateTree(oldRoute?:string) {",
" this.checkForIndex();",
" if (oldRoute) {",
" // TODO: Get delta between old and new route",
" }",
...(options.showLoading
? [
' const loadingElem = document.createElement("progress");',
" this.child.appendChild(loadingElem);",
]
: []),
" const tree = await this.renderTree();",
" // Remove children",
" while (this.child.firstChild) {",
" this.child.removeChild(this.child.firstChild);",
" }",
" // Add new children",
" if (tree) this.child.appendChild(tree);",
" this.requestUpdate();",
" }",
"",
" private async renderTree() {",
" let _route = this.route;",
" const args = this.getArgsForRoute(_route);",
" const elements: Element[] = [];",
' if (_route !== "/") {',
" while (_route.length > 0) {",
" const newChild = await this.getComponent(_route, args);",
" if (!newChild && _route === this.route) {",
' const noChild = await this.getComponent("/404", args);',
" if (noChild) elements.push(noChild);",
" break;",
" }",
" if (newChild) elements.push(newChild);",
' const parts = _route.split("/");',
" parts.pop();",
' _route = parts.join("/");',
' if (_route === "/") break;',
" }",
' } else if (_route === "/") {',
' const indexChild = await this.getComponent("/", args);',
" if (indexChild) elements.push(indexChild);",
" } else {",
' const noChild = await this.getComponent("/404", args);',
" if (noChild) elements.push(noChild);",
" }",
' const rootChild = await this.getComponent("", args);',
" if (rootChild) elements.push(rootChild);",
" let idx = elements.length - 1;",
" while (idx >= 1) {",
" const parent = elements[idx];",
" const child = elements[idx - 1];",
" if (child && parent) {",
" parent.appendChild(child);",
" }",
" idx--;",
" }",
" return elements.pop();",
" }",
"",
" private async getComponent(",
" path: string,",
" args: RegExpMatchArray | null",
" ) {",
" const applyArgs = (value: string, apply: boolean, data?: any) => {",
" const elem = document.createElement(value);",
" if (apply && args?.groups) {",
" for (const [key, value] of Object.entries(args.groups)) {",
" elem.setAttribute(key, value);",
" }",
" }",
" if (data) (elem as any).data = data;",
" return elem;",
" };",
" for (const [key, value] of Array.from(this.components.entries())) {",
" const hasArgs = path.match(fixRegex(key)) !== null;",
" if (key === path || path.match(fixRegex(key)) !== null) {",
...(options.cacheAll
? [
" const cacheKey = `${path}:${value.component}`;",
" if (this.dataCache.has(cacheKey)) {",
" const data = this.dataCache.get(cacheKey)!;",
...(options.staticImports
? []
: [" await value.loadImport();"]),
" return applyArgs(value.component, hasArgs, data);",
" }",
]
: []),
" const getLoader = await value.loadData();",
" if (getLoader) {",
" const componentData = await getLoader(this.route, args ? Object(args)['groups'] : {});",
...(options.cacheAll
? [" this.dataCache.set(cacheKey, componentData);"]
: []),
...(options.staticImports ? [] : [" await value.loadImport();"]),
" return applyArgs(value.component, hasArgs, componentData);",
" }",
...(options.staticImports ? [] : [" await value.loadImport();"]),
" return applyArgs(value.component, hasArgs);",
" }",
" }",
" return null;",
" }",
"",
" private getArgsForRoute(route: string): RegExpMatchArray | null {",
" for (const key of Array.from(this.components.keys())) {",
" const regMatch = route.match(fixRegex(key));",
" if (regMatch !== null) return regMatch;",
" }",
" return null;",
" }",
"",
" private checkForIndex() {",
' if (this.route === "" || this.route === "/") location.hash = "#/";',
' if (this.route.endsWith("/")) return;',
" const indexArgs = this.getArgsForRoute(`${this.route}/`);",
" if (indexArgs !== null) {",
" location.hash = `#${this.route}/`;",
" }",
" }",
"",
" private getCurrentRoute() {",
' let route = "/";',
' if (this.hash === "true" && window.location.hash.length > 0) {',
" route = window.location.hash.slice(1);",
' } else if (this.hash === "false") {',
' const baseUrl = this.getAttribute("base") ?? "";',
" route = window.location.pathname.slice(baseUrl.length);",
" }",
" console.debug(`current route: ${route}`);",
" return route;",
" }",
"}",
"",
"function fixRegex(route: string): RegExp {",
' const variableRegex = "[a-zA-Z0-9_-]+";',
" const nameWithParameters = route.replace(",
" new RegExp(`:(${variableRegex})`),",
" (match) => {",
" const groupName = match.slice(1);",
" return `(?<${groupName}>[a-zA-Z0-9_\\\\-.,:;+*^%$@!]+)`;",
" }",
" );",
" return new RegExp(`^${nameWithParameters}$`);",
"}",
"",
"interface Route {",
" component: string;",
" loadImport: () => Promise<any>;",
" loadData: () => Promise<RouteLoader | null>;",
"}",
"",
"type RouteLoader = (",
" route: string,",
" args: { [key: string]: any }",
") => Promise<any>;",
]);
sb.writeln();
}
@@ -0,0 +1,91 @@
import * as fs from "fs";
import { analyzePage, WebComponent } from "./analyze-page.js";
import { generateApp } from "./generate-app.js";
import { StringBuilder } from "./string-builder.js";
let inputDir = "./src/pages";
let outputFile = "./src/generated-app.ts";
let staticImports = true;
let cacheAll = false;
let showLoading = false;
const args = process.argv.slice(2);
if (args.length == 0) {
analyzePages();
} else {
// Check for -dynamic-imports=false
const noDynamicImports = args.indexOf("--dynamic-imports=false") !== -1;
staticImports = noDynamicImports;
// Check for --input-dir=<dir>
const inputDirArg = args.find((arg) => arg.startsWith("--input-dir="));
if (inputDirArg) {
inputDir = inputDirArg.replace("--input-dir=", "");
}
// Check for --output-file=<file>
const outputFileArg = args.find((arg) => arg.startsWith("--output-file="));
if (outputFileArg) {
outputFile = outputFileArg.replace("--output-file=", "");
}
// Check for --cache-all
const cacheAllArg = args.find((arg) => arg.startsWith("--cache-all"));
if (cacheAllArg) {
cacheAll = true;
}
// Check for --show-loading=false
const showLoadingArg = args.find((arg) =>
arg.startsWith("--show-loading=true")
);
showLoading = showLoadingArg ? true : false;
analyzePages();
}
function readPagesDirectory(
dir: string,
pages: { path: string; content: string }[]
) {
const files = fs.readdirSync(dir);
for (const file of files) {
if (fs.statSync(`${dir}/${file}`).isDirectory()) {
readPagesDirectory(`${dir}/${file}`, pages);
} else {
const path = `${dir}/${file}`;
const content = fs.readFileSync(path, "utf8");
pages.push({ path, content });
}
}
}
async function analyzePages() {
const sb = new StringBuilder();
// sb.writeln("// @ts-nocheck");
// sb.writeln();
let i = 0;
if (staticImports) {
sb.writeln(`// Page Routes`);
}
const components: WebComponent[] = [];
const pages: { path: string; content: string }[] = [];
readPagesDirectory(inputDir, pages);
for (const { path, content } of pages) {
// Add import
const results = analyzePage(path, content);
if (results.length > 0) {
const c = results[0];
if (staticImports) {
const filePath = path.replace("./src/", "./");
const jsPath = filePath.replace(".ts", ".js");
c.alias = `route${i}`;
sb.writeln(`import * as ${c.alias} from "${jsPath}";`);
// if (c.hasLoader) {
// sb.writeln(`import {loader as ${c.alias}Loader} from "${jsPath}";`);
// }
}
components.push(c);
}
i++;
}
sb.writeln();
generateApp(sb, components, { staticImports, cacheAll, showLoading });
const output = sb.toString();
fs.writeFileSync(outputFile, output);
}
@@ -0,0 +1,20 @@
export class StringBuilder {
private _lines: string[] = [];
write(line: string = ""): void {
this._lines.push(line);
}
writeln(line: string = ""): void {
this._lines.push(line);
this._lines.push("\n");
}
writeAll(lines: string[]): void {
this._lines.push(lines.join("\n"));
}
toString(): string {
return this._lines.join("");
}
}
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "esnext",
"lib": ["es2017", "dom", "dom.iterable"],
"declaration": true,
"emitDeclarationOnly": false,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": false
},
"include": ["src/**/*.ts"],
"exclude": []
}
+855
View File
@@ -0,0 +1,855 @@
{
"name": "lit-file-based-router",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "lit-file-based-router",
"version": "0.0.0",
"dependencies": {
"lit": "^2.0.2",
"lit-file-router": "file:lit-file-router"
},
"devDependencies": {
"@types/node": "^17.0.8",
"typescript": "^4.4.4",
"vite": "^2.7.2"
}
},
"lit-file-router": {
"version": "0.0.0",
"hasInstallScript": true,
"devDependencies": {
"@types/node": "^17.0.8",
"typescript": "^4.4.4"
}
},
"lit-file-router/node_modules/@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"dev": true
},
"lit-file-router/node_modules/typescript": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/@lit/reactive-element": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.1.0.tgz",
"integrity": "sha512-CoJHyc/us1i/dn55PqqKRtVsq6osrGp6YfnSF0OBxT81Wu2razjgTSCn4HnaHn+dy5YE9CeX4BcuS45IaJ0+8A=="
},
"node_modules/@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"dev": true
},
"node_modules/@types/trusted-types": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
},
"node_modules/esbuild": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
},
"optionalDependencies": {
"esbuild-android-arm64": "0.13.15",
"esbuild-darwin-64": "0.13.15",
"esbuild-darwin-arm64": "0.13.15",
"esbuild-freebsd-64": "0.13.15",
"esbuild-freebsd-arm64": "0.13.15",
"esbuild-linux-32": "0.13.15",
"esbuild-linux-64": "0.13.15",
"esbuild-linux-arm": "0.13.15",
"esbuild-linux-arm64": "0.13.15",
"esbuild-linux-mips64le": "0.13.15",
"esbuild-linux-ppc64le": "0.13.15",
"esbuild-netbsd-64": "0.13.15",
"esbuild-openbsd-64": "0.13.15",
"esbuild-sunos-64": "0.13.15",
"esbuild-windows-32": "0.13.15",
"esbuild-windows-64": "0.13.15",
"esbuild-windows-arm64": "0.13.15"
}
},
"node_modules/esbuild-android-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"android"
]
},
"node_modules/esbuild-darwin-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
]
},
"node_modules/esbuild-darwin-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
]
},
"node_modules/esbuild-freebsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/esbuild-freebsd-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/esbuild-linux-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-linux-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-linux-arm": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-linux-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-linux-mips64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
"cpu": [
"mips64el"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-linux-ppc64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"linux"
]
},
"node_modules/esbuild-netbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"netbsd"
]
},
"node_modules/esbuild-openbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
]
},
"node_modules/esbuild-sunos-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"sunos"
]
},
"node_modules/esbuild-windows-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
]
},
"node_modules/esbuild-windows-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
]
},
"node_modules/esbuild-windows-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
]
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/is-core-module": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz",
"integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==",
"dev": true,
"dependencies": {
"has": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/lit": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lit/-/lit-2.1.0.tgz",
"integrity": "sha512-C0YoUUzxHA1S8gR7AmgD+k9GZlw3QD2ECgARo/jMx76RfVEAmEubF9t5sON9frMEZ++YvuokR5o8FgIUF7nnag==",
"dependencies": {
"@lit/reactive-element": "^1.1.0",
"lit-element": "^3.1.0",
"lit-html": "^2.1.0"
}
},
"node_modules/lit-element": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.1.0.tgz",
"integrity": "sha512-4o5QiFwGSS1ViWWBV3nszQWTV0yAGY64zNrhQdwD+MNxRekIZpST7XqyzMQIJyKq+i9RFSTIdSURxPN1LsXGGA==",
"dependencies": {
"@lit/reactive-element": "^1.1.0",
"lit-html": "^2.1.0"
}
},
"node_modules/lit-file-router": {
"resolved": "lit-file-router",
"link": true
},
"node_modules/lit-html": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.1.0.tgz",
"integrity": "sha512-ptvlnfMBmLrs9yd8cCMOm85gc9YgICSJhOh53YEUGgEd6IGZBiEKMHgTjcoGxDvrVE7SG4alTa21aydLTWg3IA==",
"dependencies": {
"@types/trusted-types": "^2.0.2"
}
},
"node_modules/nanoid": {
"version": "3.1.30",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==",
"dev": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"dev": true
},
"node_modules/postcss": {
"version": "8.4.5",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.5.tgz",
"integrity": "sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==",
"dev": true,
"dependencies": {
"nanoid": "^3.1.30",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.1"
},
"engines": {
"node": "^10 || ^12 || >=14"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
}
},
"node_modules/resolve": {
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
"integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
"dev": true,
"dependencies": {
"is-core-module": "^2.8.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/rollup": {
"version": "2.63.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.63.0.tgz",
"integrity": "sha512-nps0idjmD+NXl6OREfyYXMn/dar3WGcyKn+KBzPdaLecub3x/LrId0wUcthcr8oZUAcZAR8NKcfGGFlNgGL1kQ==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
},
"engines": {
"node": ">=10.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/source-map-js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.1.tgz",
"integrity": "sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true,
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typescript": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/vite": {
"version": "2.7.10",
"resolved": "https://registry.npmjs.org/vite/-/vite-2.7.10.tgz",
"integrity": "sha512-KEY96ntXUid1/xJihJbgmLZx7QSC2D4Tui0FdS0Old5OokYzFclcofhtxtjDdGOk/fFpPbHv9yw88+rB93Tb8w==",
"dev": true,
"dependencies": {
"esbuild": "^0.13.12",
"postcss": "^8.4.5",
"resolve": "^1.20.0",
"rollup": "^2.59.0"
},
"bin": {
"vite": "bin/vite.js"
},
"engines": {
"node": ">=12.2.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
},
"peerDependencies": {
"less": "*",
"sass": "*",
"stylus": "*"
},
"peerDependenciesMeta": {
"less": {
"optional": true
},
"sass": {
"optional": true
},
"stylus": {
"optional": true
}
}
}
},
"dependencies": {
"@lit/reactive-element": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.1.0.tgz",
"integrity": "sha512-CoJHyc/us1i/dn55PqqKRtVsq6osrGp6YfnSF0OBxT81Wu2razjgTSCn4HnaHn+dy5YE9CeX4BcuS45IaJ0+8A=="
},
"@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"dev": true
},
"@types/trusted-types": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
},
"esbuild": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
"dev": true,
"requires": {
"esbuild-android-arm64": "0.13.15",
"esbuild-darwin-64": "0.13.15",
"esbuild-darwin-arm64": "0.13.15",
"esbuild-freebsd-64": "0.13.15",
"esbuild-freebsd-arm64": "0.13.15",
"esbuild-linux-32": "0.13.15",
"esbuild-linux-64": "0.13.15",
"esbuild-linux-arm": "0.13.15",
"esbuild-linux-arm64": "0.13.15",
"esbuild-linux-mips64le": "0.13.15",
"esbuild-linux-ppc64le": "0.13.15",
"esbuild-netbsd-64": "0.13.15",
"esbuild-openbsd-64": "0.13.15",
"esbuild-sunos-64": "0.13.15",
"esbuild-windows-32": "0.13.15",
"esbuild-windows-64": "0.13.15",
"esbuild-windows-arm64": "0.13.15"
}
},
"esbuild-android-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
"dev": true,
"optional": true
},
"esbuild-darwin-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
"dev": true,
"optional": true
},
"esbuild-darwin-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
"dev": true,
"optional": true
},
"esbuild-freebsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
"dev": true,
"optional": true
},
"esbuild-freebsd-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
"dev": true,
"optional": true
},
"esbuild-linux-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
"dev": true,
"optional": true
},
"esbuild-linux-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
"dev": true,
"optional": true
},
"esbuild-linux-arm": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
"dev": true,
"optional": true
},
"esbuild-linux-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
"dev": true,
"optional": true
},
"esbuild-linux-mips64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
"dev": true,
"optional": true
},
"esbuild-linux-ppc64le": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
"dev": true,
"optional": true
},
"esbuild-netbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
"dev": true,
"optional": true
},
"esbuild-openbsd-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
"dev": true,
"optional": true
},
"esbuild-sunos-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
"dev": true,
"optional": true
},
"esbuild-windows-32": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
"dev": true,
"optional": true
},
"esbuild-windows-64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
"dev": true,
"optional": true
},
"esbuild-windows-arm64": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
"dev": true,
"optional": true
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"is-core-module": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz",
"integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==",
"dev": true,
"requires": {
"has": "^1.0.3"
}
},
"lit": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lit/-/lit-2.1.0.tgz",
"integrity": "sha512-C0YoUUzxHA1S8gR7AmgD+k9GZlw3QD2ECgARo/jMx76RfVEAmEubF9t5sON9frMEZ++YvuokR5o8FgIUF7nnag==",
"requires": {
"@lit/reactive-element": "^1.1.0",
"lit-element": "^3.1.0",
"lit-html": "^2.1.0"
}
},
"lit-element": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.1.0.tgz",
"integrity": "sha512-4o5QiFwGSS1ViWWBV3nszQWTV0yAGY64zNrhQdwD+MNxRekIZpST7XqyzMQIJyKq+i9RFSTIdSURxPN1LsXGGA==",
"requires": {
"@lit/reactive-element": "^1.1.0",
"lit-html": "^2.1.0"
}
},
"lit-file-router": {
"version": "file:lit-file-router",
"requires": {
"@types/node": "^17.0.8",
"typescript": "^4.4.4"
},
"dependencies": {
"@types/node": {
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"dev": true
},
"typescript": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
"dev": true
}
}
},
"lit-html": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.1.0.tgz",
"integrity": "sha512-ptvlnfMBmLrs9yd8cCMOm85gc9YgICSJhOh53YEUGgEd6IGZBiEKMHgTjcoGxDvrVE7SG4alTa21aydLTWg3IA==",
"requires": {
"@types/trusted-types": "^2.0.2"
}
},
"nanoid": {
"version": "3.1.30",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz",
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==",
"dev": true
},
"path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"dev": true
},
"postcss": {
"version": "8.4.5",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.5.tgz",
"integrity": "sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==",
"dev": true,
"requires": {
"nanoid": "^3.1.30",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.1"
}
},
"resolve": {
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
"integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
"dev": true,
"requires": {
"is-core-module": "^2.8.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
}
},
"rollup": {
"version": "2.63.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.63.0.tgz",
"integrity": "sha512-nps0idjmD+NXl6OREfyYXMn/dar3WGcyKn+KBzPdaLecub3x/LrId0wUcthcr8oZUAcZAR8NKcfGGFlNgGL1kQ==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
}
},
"source-map-js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.1.tgz",
"integrity": "sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==",
"dev": true
},
"supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true
},
"typescript": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
"integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
"dev": true
},
"vite": {
"version": "2.7.10",
"resolved": "https://registry.npmjs.org/vite/-/vite-2.7.10.tgz",
"integrity": "sha512-KEY96ntXUid1/xJihJbgmLZx7QSC2D4Tui0FdS0Old5OokYzFclcofhtxtjDdGOk/fFpPbHv9yw88+rB93Tb8w==",
"dev": true,
"requires": {
"esbuild": "^0.13.12",
"fsevents": "~2.3.2",
"postcss": "^8.4.5",
"resolve": "^1.20.0",
"rollup": "^2.59.0"
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"name": "lit-file-based-router",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite serve",
"start": "npm run dev",
"prebuild": "tsc && npm run generate",
"generate": "node lit-file-router --dynamic-imports=true --cache-all --show-loading=true"
},
"dependencies": {
"lit": "^2.0.2",
"lit-file-router": "file:lit-file-router"
},
"devDependencies": {
"@types/node": "^17.0.8",
"typescript": "^4.4.4",
"vite": "^2.7.2"
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("menu-button")
export class MenuButton extends LitElement {
static styles = css``;
render() {
return html` <button @click=${() => alert('Menu Toggle')}>Menu</button> `;
}
}
+15
View File
@@ -0,0 +1,15 @@
<svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)"/>
<path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
<stop stop-color="#41D1FF"/>
<stop offset="1" stop-color="#BD34FE"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFEA83"/>
<stop offset="0.0833333" stop-color="#FFDD35"/>
<stop offset="1" stop-color="#FFA800"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+261
View File
@@ -0,0 +1,261 @@
import { html, css, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators.js";
@customElement("generated-app")
export class GeneratedApp extends LitElement {
static styles = css`
main {
width: 100%;
height: 100%;
}
progress {
position: absolute;
bottom: 0;
width: calc(100% - 1rem);
z-index: 1;
left: 0.5rem;
right: 0.5rem;
}
`;
@property() hash = 'true';
@property() base = '/';
@state() loading = false;
@property() route = this.getCurrentRoute();
@state() child = document.createElement('main');
dataCache = new Map<string, any>();
components: Map<string, Route> = new Map([
["/404", {
component: "unknown-route",
loadData: async () => null,
loadImport: () => import("./pages/404.js"),
}],
["/custom/not/nested/route", {
component: "custom-route",
loadData: async () => null,
loadImport: () => import("./pages/custom.not.nested.route.js"),
}],
["/dashboard/account/:id", {
component: "account-details",
loadData: async () => {
const {loader} = await import("./pages/dashboard/account/:id.js");
return loader;
},
loadImport: () => import("./pages/dashboard/account/:id.js"),
}],
["/dashboard/account/", {
component: "account-info",
loadData: async () => null,
loadImport: () => import("./pages/dashboard/account/index.js"),
}],
["/dashboard/account", {
component: "account-module",
loadData: async () => null,
loadImport: () => import("./pages/dashboard/account.js"),
}],
["/dashboard/", {
component: "dashboard-default",
loadData: async () => null,
loadImport: () => import("./pages/dashboard/index.js"),
}],
["/dashboard/overview", {
component: "overview-module",
loadData: async () => null,
loadImport: () => import("./pages/dashboard/overview.js"),
}],
["/dashboard", {
component: "dashboard-module",
loadData: async () => null,
loadImport: () => import("./pages/dashboard.js"),
}],
["/", {
component: "app-module",
loadData: async () => null,
loadImport: () => import("./pages/index.js"),
}],
["", {
component: "root-module",
loadData: async () => null,
loadImport: () => import("./pages/root.js"),
}],
["/settings/admin", {
component: "admin-settings",
loadData: async () => null,
loadImport: () => import("./pages/settings/admin.js"),
}],
["/settings/", {
component: "settings-default",
loadData: async () => null,
loadImport: () => import("./pages/settings/index.js"),
}],
["/settings", {
component: "settings-module",
loadData: async () => null,
loadImport: () => import("./pages/settings.js"),
}],
]);
firstUpdated() {
window.addEventListener("hashchange", () => {
const oldRoute = this.route;
this.route = this.getCurrentRoute();
this.updateTree(oldRoute);
});
this.updateTree();
}
render() {
return html` ${this.child} `;
}
refresh() {
return this.updateTree();
}
private async updateTree(oldRoute?:string) {
this.checkForIndex();
if (oldRoute) {
// TODO: Get delta between old and new route
}
const loadingElem = document.createElement("progress");
this.child.appendChild(loadingElem);
const tree = await this.renderTree();
// Remove children
while (this.child.firstChild) {
this.child.removeChild(this.child.firstChild);
}
// Add new children
if (tree) this.child.appendChild(tree);
this.requestUpdate();
}
private async renderTree() {
let _route = this.route;
const args = this.getArgsForRoute(_route);
const elements: Element[] = [];
if (_route !== "/") {
while (_route.length > 0) {
const newChild = await this.getComponent(_route, args);
if (!newChild && _route === this.route) {
const noChild = await this.getComponent("/404", args);
if (noChild) elements.push(noChild);
break;
}
elements.push(newChild!);
const parts = _route.split("/");
parts.pop();
_route = parts.join("/");
if (_route === "/") break;
}
} else if (_route === "/") {
const indexChild = await this.getComponent("/", args);
if (indexChild) elements.push(indexChild);
} else {
const noChild = await this.getComponent("/404", args);
if (noChild) elements.push(noChild);
}
const rootChild = await this.getComponent("", args);
if (rootChild) elements.push(rootChild);
let idx = elements.length - 1;
while (idx >= 1) {
const parent = elements[idx];
const child = elements[idx - 1];
if (child && parent) {
parent.appendChild(child);
}
idx--;
}
return elements.pop();
}
private async getComponent(
path: string,
args: RegExpMatchArray | null
) {
const applyArgs = (value: string, apply: boolean, data?: any) => {
const elem = document.createElement(value);
if (apply && args?.groups) {
for (const [key, value] of Object.entries(args.groups)) {
elem.setAttribute(key, value);
}
}
if (data) (elem as any).data = data;
return elem;
};
for (const [key, value] of Array.from(this.components.entries())) {
const hasArgs = path.match(fixRegex(key)) !== null;
if (key === path || path.match(fixRegex(key)) !== null) {
const cacheKey = `${path}:${value.component}`;
if (this.dataCache.has(cacheKey)) {
const data = this.dataCache.get(cacheKey)!;
await value.loadImport();
return applyArgs(value.component, hasArgs, data);
}
const getLoader = await value.loadData();
if (getLoader) {
const componentData = await getLoader(this.route, args ? Object(args)['groups'] : {});
this.dataCache.set(cacheKey, componentData);
await value.loadImport();
return applyArgs(value.component, hasArgs, componentData);
}
await value.loadImport();
return applyArgs(value.component, hasArgs);
}
}
return null;
}
private getArgsForRoute(route: string): RegExpMatchArray | null {
for (const key of Array.from(this.components.keys())) {
const regMatch = route.match(fixRegex(key));
if (regMatch !== null) return regMatch;
}
return null;
}
private checkForIndex() {
if (this.route === "" || this.route === "/") location.hash = "#/";
if (this.route.endsWith("/")) return;
const indexArgs = this.getArgsForRoute(`${this.route}/`);
if (indexArgs !== null) {
location.hash = `#${this.route}/`;
}
}
private getCurrentRoute() {
let route = "/";
if (this.hash === "true" && window.location.hash.length > 0) {
route = window.location.hash.slice(1);
} else if (this.hash === "false") {
const baseUrl = this.getAttribute("base") ?? "";
route = window.location.pathname.slice(baseUrl.length);
}
console.debug(`current route: ${route}`);
return route;
}
}
function fixRegex(route: string): RegExp {
const variableRegex = "[a-zA-Z0-9_-]+";
const nameWithParameters = route.replace(
new RegExp(`:(${variableRegex})`),
(match) => {
const groupName = match.slice(1);
return `(?<${groupName}>[a-zA-Z0-9_\\-.,:;+*^%$@!]+)`;
}
);
return new RegExp(`^${nameWithParameters}$`);
}
interface Route {
component: string;
loadImport: () => Promise<any>;
loadData: () => Promise<RouteLoader | null>;
}
type RouteLoader = (
route: string,
args: { [key: string]: any }
) => Promise<any>;
+13
View File
@@ -0,0 +1,13 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("unknown-route")
export class UnknownRoute extends LitElement {
static styles = css``;
render() {
return html` <main>
<header>404</header>
</main>`;
}
}
@@ -0,0 +1,13 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("custom-route")
export class CustomRoute extends LitElement {
static styles = css``;
render() {
return html` <main>
<header>Custom</header>
</main>`;
}
}
@@ -0,0 +1,35 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import '../components/menu-button.js';
@customElement("dashboard-module")
export class DashboardModule extends LitElement {
static styles = css`
header {
height: 40px;
background-color: orange;
color: white;
display: flex;
flex-direction: row;
align-items: center;
padding-left: 10px;
padding-right: 10px;
justify-content: space-between;
}
`;
render() {
return html`<main>
<header>
<menu-button></menu-button>
<span class="title">Dashboard</span>
<nav>
<a href="#/dashboard/overview">Overview</a>
<a href="#/dashboard/account/">Account</a>
</nav>
</header>
<section><slot></slot></section>
</main> `;
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("account-module")
export class AccountModule extends LitElement {
static styles = css``;
render() {
return html`<section><slot></slot></section>`;
}
}
@@ -0,0 +1,33 @@
import { html, css, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
export async function loader(
route: string,
args: { [key: string]: any }
): Promise<AccountData> {
await new Promise((resolve) => setTimeout(resolve, 1000));
const id = args["id"]!;
return {
id,
route,
name: "Name: " + id,
};
}
@customElement("account-details")
export class AccountDetails extends LitElement {
static styles = css``;
@property({ type: String }) id = "";
@property({ type: Object }) data!: AccountData;
render() {
return html`<section>${this.data.name}</section>`;
}
}
interface AccountData {
id: string;
route: string;
name: string;
}
@@ -0,0 +1,22 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("account-info")
export class AccountInfo extends LitElement {
static styles = css`
article {
padding: 16px;
}
`;
render() {
return html`<article>
<h3>Account Info</h3>
<ul>
<li><a href="#/dashboard/account/1">User 1</a></li>
<li><a href="#/dashboard/account/2">User 2</a></li>
<li><a href="#/dashboard/account/3">User 3</a></li>
</ul>
</article>`;
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("dashboard-default")
export class DashboardDefault extends LitElement {
static styles = css``;
render() {
return html`<section>Default Dashboard</section>`;
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("overview-module")
export class OverviewModule extends LitElement {
static styles = css``;
render() {
return html`<section>Overview</section>`;
}
}
+24
View File
@@ -0,0 +1,24 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("app-module")
export class AppModule extends LitElement {
static styles = css`
header {
height: 40px;
background-color: navy;
color: white;
display: flex;
flex-direction: row;
align-items: center;
padding-left: 10px;
}
`;
render() {
return html` <main>
<header>App Base</header>
<slot></slot>
</main>`;
}
}
+36
View File
@@ -0,0 +1,36 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("root-module")
export class RootModule extends LitElement {
static styles = css`
main {
display: flex;
flex-direction: row;
height: 100vh;
width: 100%;
}
aside {
display: flex;
flex-direction: column;
background-color: whitesmoke;
padding: 8px;
}
section {
flex: 1;
}
`;
render() {
return html`
<main>
<aside>
<a href="#/">Home</a>
<a href="#/dashboard">Dashboard</a>
<a href="#/settings">Settings</a>
</aside>
<section><slot></slot></section>
</main>
`;
}
}
@@ -0,0 +1,31 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import "../components/menu-button.js";
@customElement("settings-module")
export class SettingsModule extends LitElement {
static styles = css`
header {
height: 40px;
background-color: black;
color: white;
display: flex;
flex-direction: row;
align-items: center;
padding-left: 10px;
justify-content: space-between;
}
`;
render() {
return html` <main>
<header>
<menu-button></menu-button>
<span class="title">Settings</span>
<div></div>
</header>
<slot></slot>
</main>`;
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("admin-settings")
export class AdminSettings extends LitElement {
static styles = css``;
render() {
return html`Admin Settings`;
}
}
@@ -0,0 +1,11 @@
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
@customElement("settings-default")
export class SettingsDefault extends LitElement {
static styles = css``;
render() {
return html`<section>Default Settings</section>`;
}
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "esnext",
"lib": [
"es2017",
"dom",
"dom.iterable"
],
"declaration": true,
// "emitDeclarationOnly": true,
"esModuleInterop": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": false
},
"include": [
"src/**/*.ts"
],
"exclude": []
}
+11
View File
@@ -0,0 +1,11 @@
import { defineConfig } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
base: "/lit-file-based-routing/",
build: {
rollupOptions: {
input: "index.html",
},
},
});