exploRUG component setup
This commit is contained in:
21
.eleventy.cjs
Normal file
21
.eleventy.cjs
Normal file
@@ -0,0 +1,21 @@
|
||||
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
|
||||
|
||||
module.exports = function (eleventyConfig) {
|
||||
eleventyConfig.addPlugin(syntaxHighlight);
|
||||
eleventyConfig.addPassthroughCopy('docs-src/docs.css');
|
||||
eleventyConfig.addPassthroughCopy('docs-src/.nojekyll');
|
||||
eleventyConfig.addPassthroughCopy(
|
||||
'node_modules/@webcomponents/webcomponentsjs'
|
||||
);
|
||||
eleventyConfig.addPassthroughCopy('node_modules/lit/polyfill-support.js');
|
||||
return {
|
||||
dir: {
|
||||
input: 'docs-src',
|
||||
output: 'docs',
|
||||
},
|
||||
templateExtensionAliases: {
|
||||
'11ty.cjs': '11ty.js',
|
||||
'11tydata.cjs': '11tydata.js',
|
||||
},
|
||||
};
|
||||
};
|
||||
6
.eslintignore
Normal file
6
.eslintignore
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules/*
|
||||
docs/*
|
||||
docs-src/*
|
||||
rollup-config.js
|
||||
custom-elements.json
|
||||
web-dev-server.config.js
|
||||
51
.eslintrc.json
Normal file
51
.eslintrc.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"env": {
|
||||
"browser": true
|
||||
},
|
||||
"rules": {
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"argsIgnorePattern": "^_"
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["rollup.config.js", "web-test-runner.config.js"],
|
||||
"env": {
|
||||
"node": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*_test.ts",
|
||||
"**/custom_typings/*.ts",
|
||||
"packages/labs/ssr/src/test/integration/tests/**",
|
||||
"packages/labs/ssr/src/lib/util/parse5-utils.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
44
.gitignore
vendored
Normal file
44
.gitignore
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/node_modules/
|
||||
/lib/
|
||||
/test/
|
||||
custom-elements.json
|
||||
# Build outputs (generated — should not be tracked)
|
||||
/dist/
|
||||
/docs/
|
||||
|
||||
# TypeScript incremental build cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Vite cache
|
||||
.vite/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# macOS metadata
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
|
||||
# Environment variables (never commit secrets)
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Editor/IDE directories
|
||||
.vscode/
|
||||
.idea/
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
|
||||
# Test coverage
|
||||
coverage/
|
||||
|
||||
# Yarn
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
7
.prettierrc.json
Normal file
7
.prettierrc.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "always"
|
||||
}
|
||||
115
CHANGELOG.md
Normal file
115
CHANGELOG.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# @lit/lit-starter-ts
|
||||
|
||||
## 2.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4984](https://github.com/lit/lit/pull/4984) [`ad23f26ae908a160d30ed2a939b322fe9cc2ee83`](https://github.com/lit/lit/commit/ad23f26ae908a160d30ed2a939b322fe9cc2ee83) Thanks [@kyubisation](https://github.com/kyubisation)! - Update TypeScript dependencies to version 5.8 with related ARIAMixin changes (ariaColIndexText, ariaRelevant and ariaRowIndexText)
|
||||
|
||||
## 2.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4682](https://github.com/lit/lit/pull/4682) [`290a608a`](https://github.com/lit/lit/commit/290a608aa2297e8b99a5424dc90632b97c66386c) - Update typescript to 5.5.0
|
||||
|
||||
- [#4681](https://github.com/lit/lit/pull/4681) [`5463b104`](https://github.com/lit/lit/commit/5463b1046e0589c9ce7041e67cd539ddfba2e5a7) - Update Rollup and Terser dependencies
|
||||
|
||||
- Updated dependencies [[`feccc1ba`](https://github.com/lit/lit/commit/feccc1ba8e82b36d07a0e2576381bf2819926b98)]:
|
||||
- lit@3.2.0
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4451](https://github.com/lit/lit/pull/4451) [`7852e130`](https://github.com/lit/lit/commit/7852e13022c9dcfcff5ed54a215c93420349e318) - Minor security fixes.
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#4141](https://github.com/lit/lit/pull/4141) [`6b515e43`](https://github.com/lit/lit/commit/6b515e43c3a24cc8a593247d3aa72d81bcc724d5) - Update TypeScript to ~5.2.0
|
||||
|
||||
- [#3756](https://github.com/lit/lit/pull/3756) [`f06f7972`](https://github.com/lit/lit/commit/f06f7972a027d2937fe2c68ab5af0274dec57cf4) - Drop IE11 support
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3814](https://github.com/lit/lit/pull/3814) [`23326c6b`](https://github.com/lit/lit/commit/23326c6b9a6abdf01998dadf5d0f20a643e457aa) - Update to TypeScript v5.0
|
||||
|
||||
- Updated dependencies [[`dfd747cf`](https://github.com/lit/lit/commit/dfd747cf4f7239e0c3bb7134f8acb967d0157654), [`6b515e43`](https://github.com/lit/lit/commit/6b515e43c3a24cc8a593247d3aa72d81bcc724d5), [`23c404fd`](https://github.com/lit/lit/commit/23c404fdec0cd7be834221b6ddf9b659c24ca8a2), [`1040f758`](https://github.com/lit/lit/commit/1040f75861b029527538b4ec36b2cfedcc32988a), [`0f6878dc`](https://github.com/lit/lit/commit/0f6878dc45fd95bbeb8750f277349c1392e2b3ad), [`1db01376`](https://github.com/lit/lit/commit/1db0137699b35d7e7bfac9b2ab274af4100fd7cf), [`2a01471a`](https://github.com/lit/lit/commit/2a01471a5f65fe34bad11e1099281811b8d0f79b), [`6f2833fd`](https://github.com/lit/lit/commit/6f2833fd05f2ecde5386f72d291dafc9dbae0cf7), [`c3e473b4`](https://github.com/lit/lit/commit/c3e473b499ff029b5e1aff01ca8799daf1ca1bbe), [`2eba6997`](https://github.com/lit/lit/commit/2eba69974c9e130e7483f44f9daca308345497d5), [`92cedaa2`](https://github.com/lit/lit/commit/92cedaa2c8cd8a306be3fe25d52e0e47bb044020), [`d27a77ec`](https://github.com/lit/lit/commit/d27a77ec3d3999e872df9218a2b07f90f22eb417), [`7e8491d4`](https://github.com/lit/lit/commit/7e8491d4ed9f0c39d974616c4678552ef50b81df), [`6470807f`](https://github.com/lit/lit/commit/6470807f3a0981f9d418cb26f05969912455d148), [`23326c6b`](https://github.com/lit/lit/commit/23326c6b9a6abdf01998dadf5d0f20a643e457aa), [`09949234`](https://github.com/lit/lit/commit/09949234445388d51bfb4ee24ff28a4c9f82fe17), [`f06f7972`](https://github.com/lit/lit/commit/f06f7972a027d2937fe2c68ab5af0274dec57cf4)]:
|
||||
- lit@3.0.0
|
||||
|
||||
## 2.0.0-pre.1
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#4141](https://github.com/lit/lit/pull/4141) [`6b515e43`](https://github.com/lit/lit/commit/6b515e43c3a24cc8a593247d3aa72d81bcc724d5) - Update TypeScript to ~5.2.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`6b515e43`](https://github.com/lit/lit/commit/6b515e43c3a24cc8a593247d3aa72d81bcc724d5), [`0f6878dc`](https://github.com/lit/lit/commit/0f6878dc45fd95bbeb8750f277349c1392e2b3ad), [`2a01471a`](https://github.com/lit/lit/commit/2a01471a5f65fe34bad11e1099281811b8d0f79b), [`2eba6997`](https://github.com/lit/lit/commit/2eba69974c9e130e7483f44f9daca308345497d5), [`d27a77ec`](https://github.com/lit/lit/commit/d27a77ec3d3999e872df9218a2b07f90f22eb417), [`6470807f`](https://github.com/lit/lit/commit/6470807f3a0981f9d418cb26f05969912455d148), [`09949234`](https://github.com/lit/lit/commit/09949234445388d51bfb4ee24ff28a4c9f82fe17)]:
|
||||
- lit@3.0.0-pre.1
|
||||
|
||||
## 2.0.0-pre.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#3756](https://github.com/lit/lit/pull/3756) [`f06f7972`](https://github.com/lit/lit/commit/f06f7972a027d2937fe2c68ab5af0274dec57cf4) - Drop IE11 support
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3814](https://github.com/lit/lit/pull/3814) [`23326c6b`](https://github.com/lit/lit/commit/23326c6b9a6abdf01998dadf5d0f20a643e457aa) - Update to TypeScript v5.0
|
||||
|
||||
- Updated dependencies [[`dfd747cf`](https://github.com/lit/lit/commit/dfd747cf4f7239e0c3bb7134f8acb967d0157654), [`23c404fd`](https://github.com/lit/lit/commit/23c404fdec0cd7be834221b6ddf9b659c24ca8a2), [`1db01376`](https://github.com/lit/lit/commit/1db0137699b35d7e7bfac9b2ab274af4100fd7cf), [`c3e473b4`](https://github.com/lit/lit/commit/c3e473b499ff029b5e1aff01ca8799daf1ca1bbe), [`92cedaa2`](https://github.com/lit/lit/commit/92cedaa2c8cd8a306be3fe25d52e0e47bb044020), [`23326c6b`](https://github.com/lit/lit/commit/23326c6b9a6abdf01998dadf5d0f20a643e457aa), [`f06f7972`](https://github.com/lit/lit/commit/f06f7972a027d2937fe2c68ab5af0274dec57cf4)]:
|
||||
- lit@3.0.0-pre.0
|
||||
|
||||
## 1.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4157](https://github.com/lit/lit/pull/4157) [`da32db2e`](https://github.com/lit/lit/commit/da32db2e67547e0f17b7132065559eba2b1d3513) Thanks [@welingtonms](https://github.com/welingtonms)! - Improve bundling and minification recommendations.
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3561](https://github.com/lit/lit/pull/3561) [`e5c254e9`](https://github.com/lit/lit/commit/e5c254e96cb5d0f770ec616332e231559325c5c5) - Update dependency `@rollup/plugin-replace`
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2922](https://github.com/lit/lit/pull/2922) [`da9db86a`](https://github.com/lit/lit/commit/da9db86a33cba710d439e254df2492f9f6dcbbee) - Update dependencies and remove unused dependencies
|
||||
|
||||
## 1.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2757](https://github.com/lit/lit/pull/2757) [`55841c14`](https://github.com/lit/lit/commit/55841c14f52891357dd93680d3bc5b1da6c89c8a) - Update Rollup and Rollup plugins
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2535](https://github.com/lit/lit/pull/2535) [`d1359856`](https://github.com/lit/lit/commit/d1359856698d1af381b335fb757f9282574690b0) - Update the README to indicate that issues and PRs should be filed on the main Lit repo.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2300](https://github.com/lit/lit/pull/2300) [`8b9dcb4d`](https://github.com/lit/lit/commit/8b9dcb4d10e4161083146ae40d0b12174a63d31d) - Fix starter kits so `npm run serve` serves the root directory, and add a link to the `/dev/index.html` component example from `/`.
|
||||
|
||||
- Updated dependencies [[`fcc2b3d0`](https://github.com/lit/lit/commit/fcc2b3d0054e69e6f76588ea9f440117b6d0deed), [`49ecf623`](https://github.com/lit/lit/commit/49ecf6239033e9578184d46116e6b89676d091db), [`1d563e83`](https://github.com/lit/lit/commit/1d563e830c02a2d1a22e1e939f1ace971b1d1ae7)]:
|
||||
- lit@2.1.0
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2113](https://github.com/lit/lit/pull/2113) [`5b2f3642`](https://github.com/lit/lit/commit/5b2f3642ff91931b5b01f8bdd2ed98aba24f1047) - Dependency upgrades including TypeScript 4.4.2
|
||||
|
||||
- [#2103](https://github.com/lit/lit/pull/2103) [`15a8356d`](https://github.com/lit/lit/commit/15a8356ddd59a1e80880a93acd21fadc9c24e14b) - Added Lit dev mode to test and serve commands, controlled via the MODE=dev or MODE=prod environment variables.
|
||||
|
||||
- [#2117](https://github.com/lit/lit/pull/2117) [`eff2fbc7`](https://github.com/lit/lit/commit/eff2fbc7e45cfc2a7b8df21e18c84619dfbcb277) - Updated starter templates to use open-wc analyzer for generating custom-elements.json, and updated basic API docs generater included in the template to the new manifest format.
|
||||
|
||||
- Updated dependencies [[`15a8356d`](https://github.com/lit/lit/commit/15a8356ddd59a1e80880a93acd21fadc9c24e14b), [`5fabe2b5`](https://github.com/lit/lit/commit/5fabe2b5ae4ab8fba9dc2d23a69105d32e4c0705), [`5b2f3642`](https://github.com/lit/lit/commit/5b2f3642ff91931b5b01f8bdd2ed98aba24f1047), [`5fabe2b5`](https://github.com/lit/lit/commit/5fabe2b5ae4ab8fba9dc2d23a69105d32e4c0705), [`5fabe2b5`](https://github.com/lit/lit/commit/5fabe2b5ae4ab8fba9dc2d23a69105d32e4c0705), [`0312f3e5`](https://github.com/lit/lit/commit/0312f3e533611eb3f4f9381594485a33ad003b74)]:
|
||||
- lit@2.0.0
|
||||
28
LICENSE
Normal file
28
LICENSE
Normal file
@@ -0,0 +1,28 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2019 Google LLC. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
154
README.md
Normal file
154
README.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# LitElement TypeScript starter
|
||||
|
||||
This project includes a sample component using LitElement with TypeScript.
|
||||
|
||||
This template is generated from the `lit-starter-ts` package in [the main Lit
|
||||
repo](https://github.com/lit/lit). Issues and PRs for this template should be
|
||||
filed in that repo.
|
||||
|
||||
## About this release
|
||||
|
||||
This is a pre-release of Lit 3.0, the next major version of Lit.
|
||||
|
||||
Lit 3.0 has very few breaking changes from Lit 2.0:
|
||||
|
||||
- Drops support for IE11
|
||||
- Published as ES2021
|
||||
- Removes a couple of deprecated Lit 1.x APIs
|
||||
|
||||
Lit 3.0 should require no changes to upgrade from Lit 2.0 for the vast majority of users. Once the full release is published, most apps and libraries will be able to extend their npm version ranges to include both 2.x and 3.x, like `"^2.7.0 || ^3.0.0"`.
|
||||
|
||||
Lit 2.x and 3.0 are _interoperable_: templates, base classes, directives, decorators, etc., from one version of Lit will work with those from another.
|
||||
|
||||
Please file any issues you find on our [issue tracker](https://github.com/lit/lit/issues).
|
||||
|
||||
## Setup
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```bash
|
||||
npm i
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.
|
||||
|
||||
To build the JavaScript version of your component:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
To watch files and rebuild when the files are modified, run the following command in a separate shell:
|
||||
|
||||
```bash
|
||||
npm run build:watch
|
||||
```
|
||||
|
||||
Both the TypeScript compiler and lit-analyzer are configured to be very strict. You may want to change `tsconfig.json` to make them less strict.
|
||||
|
||||
## Testing
|
||||
|
||||
This sample uses modern-web.dev's
|
||||
[@web/test-runner](https://www.npmjs.com/package/@web/test-runner) for testing. See the
|
||||
[modern-web.dev testing documentation](https://modern-web.dev/docs/test-runner/overview) for
|
||||
more information.
|
||||
|
||||
Tests can be run with the `test` script, which will run your tests against Lit's development mode (with more verbose errors) as well as against Lit's production mode:
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
For local testing during development, the `test:dev:watch` command will run your tests in Lit's development mode (with verbose errors) on every change to your source files:
|
||||
|
||||
```bash
|
||||
npm test:watch
|
||||
```
|
||||
|
||||
Alternatively the `test:prod` and `test:prod:watch` commands will run your tests in Lit's production mode.
|
||||
|
||||
## Dev Server
|
||||
|
||||
This sample uses modern-web.dev's [@web/dev-server](https://www.npmjs.com/package/@web/dev-server) for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See [modern-web.dev's Web Dev Server documentation](https://modern-web.dev/docs/dev-server/overview/) for more information.
|
||||
|
||||
To run the dev server and open the project in a new browser tab:
|
||||
|
||||
```bash
|
||||
npm run serve
|
||||
```
|
||||
|
||||
There is a development HTML file located at `/dev/index.html` that you can view at http://localhost:8000/dev/index.html. Note that this command will serve your code using Lit's development mode (with more verbose errors). To serve your code against Lit's production mode, use `npm run serve:prod`.
|
||||
|
||||
## Editing
|
||||
|
||||
If you use VS Code, we highly recommend the [lit-plugin extension](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin), which enables some extremely useful features for lit-html templates:
|
||||
|
||||
- Syntax highlighting
|
||||
- Type-checking
|
||||
- Code completion
|
||||
- Hover-over docs
|
||||
- Jump to definition
|
||||
- Linting
|
||||
- Quick Fixes
|
||||
|
||||
The project is setup to recommend lit-plugin to VS Code users if they don't already have it installed.
|
||||
|
||||
## Linting
|
||||
|
||||
Linting of TypeScript files is provided by [ESLint](eslint.org) and [TypeScript ESLint](https://github.com/typescript-eslint/typescript-eslint). In addition, [lit-analyzer](https://www.npmjs.com/package/lit-analyzer) is used to type-check and lint lit-html templates with the same engine and rules as lit-plugin.
|
||||
|
||||
The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing `.eslintrc.json` and `tsconfig.json`.
|
||||
|
||||
To lint the project run:
|
||||
|
||||
```bash
|
||||
npm run lint
|
||||
```
|
||||
|
||||
## Formatting
|
||||
|
||||
[Prettier](https://prettier.io/) is used for code formatting. It has been pre-configured according to the Lit's style. You can change this in `.prettierrc.json`.
|
||||
|
||||
Prettier has not been configured to run when committing files, but this can be added with Husky and `pretty-quick`. See the [prettier.io](https://prettier.io/) site for instructions.
|
||||
|
||||
## Static Site
|
||||
|
||||
This project includes a simple website generated with the [eleventy](https://11ty.dev) static site generator and the templates and pages in `/docs-src`. The site is generated to `/docs` and intended to be checked in so that GitHub pages can serve the site [from `/docs` on the main branch](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).
|
||||
|
||||
To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "main branch /docs folder".</p>
|
||||
|
||||
To build the site, run:
|
||||
|
||||
```bash
|
||||
npm run docs
|
||||
```
|
||||
|
||||
To serve the site locally, run:
|
||||
|
||||
```bash
|
||||
npm run docs:serve
|
||||
```
|
||||
|
||||
To watch the site files, and re-build automatically, run:
|
||||
|
||||
```bash
|
||||
npm run docs:gen:watch
|
||||
```
|
||||
|
||||
The site will usually be served at http://localhost:8000.
|
||||
|
||||
**Note**: The project uses Rollup to bundle and minify the source code for the docs site and not to publish to NPM. For bundling and minification, check the [Bundling and minification](#bundling-and-minification) section.
|
||||
|
||||
## Bundling and minification
|
||||
|
||||
As stated in the [static site generation](#static-site) section, the bundling and minification setup in the Rollup configuration in this project is there specifically for the docs generation.
|
||||
|
||||
We recommend publishing components as unoptimized JavaScript modules and performing build-time optimizations at the application level. This gives build tools the best chance to deduplicate code, remove dead code, and so on.
|
||||
|
||||
Please check the [Publishing best practices](https://lit.dev/docs/tools/publishing/#publishing-best-practices) for information on publishing reusable Web Components, and [Build for production](https://lit.dev/docs/tools/production/) for building application projects that include LitElement components, on the Lit site.
|
||||
|
||||
## More information
|
||||
|
||||
See [Get started](https://lit.dev/docs/getting-started/) on the Lit site for more information.
|
||||
2
docs-src/.eleventyignore
Normal file
2
docs-src/.eleventyignore
Normal file
@@ -0,0 +1,2 @@
|
||||
# Ignore files with a leading underscore; useful for e.g. readmes in source documentation
|
||||
_*.md
|
||||
0
docs-src/.nojekyll
Normal file
0
docs-src/.nojekyll
Normal file
7
docs-src/_README.md
Normal file
7
docs-src/_README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
This directory contains the sources for the static site contained in the /docs/ directory. The site is based on the [eleventy](11ty.dev) static site generator.
|
||||
|
||||
The site is intended to be used with GitHub pages. To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "master branch /docs folder".
|
||||
|
||||
To view the site locally, run `npm run docs:serve`.
|
||||
|
||||
To edit the site, add to or edit the files in this directory then run `npm run docs` to build the site. The built files must be checked in and pushed to GitHub to appear on GitHub pages.
|
||||
16
docs-src/_data/api.11tydata.js
Normal file
16
docs-src/_data/api.11tydata.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = () => {
|
||||
const customElements = JSON.parse(
|
||||
fs.readFileSync('custom-elements.json', 'utf-8')
|
||||
);
|
||||
return {
|
||||
customElements,
|
||||
};
|
||||
};
|
||||
43
docs-src/_includes/example.11ty.cjs
Normal file
43
docs-src/_includes/example.11ty.cjs
Normal file
@@ -0,0 +1,43 @@
|
||||
const page = require('./page.11ty.cjs');
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
/**
|
||||
* This template extends the page template and adds an examples list.
|
||||
*/
|
||||
module.exports = function (data) {
|
||||
return page({
|
||||
...data,
|
||||
content: renderExample(data),
|
||||
});
|
||||
};
|
||||
|
||||
const renderExample = ({name, content, collections, page}) => {
|
||||
return `
|
||||
<h1>Example: ${name}</h1>
|
||||
<section class="examples">
|
||||
<nav class="collection">
|
||||
<ul>
|
||||
${
|
||||
collections.example === undefined
|
||||
? ''
|
||||
: collections.example
|
||||
.map(
|
||||
(post) => `
|
||||
<li class=${post.url === page.url ? 'selected' : ''}>
|
||||
<a href="${relative(
|
||||
page.url,
|
||||
post.url
|
||||
)}">${post.data.description.replace(/</g, '<')}</a>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
<div>
|
||||
${content}
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
};
|
||||
9
docs-src/_includes/footer.11ty.cjs
Normal file
9
docs-src/_includes/footer.11ty.cjs
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/lit/lit-element-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>`;
|
||||
};
|
||||
7
docs-src/_includes/header.11ty.cjs
Normal file
7
docs-src/_includes/header.11ty.cjs
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<header>
|
||||
<h1><my-element></h1>
|
||||
<h2>A web component just for me.</h2>
|
||||
</header>`;
|
||||
};
|
||||
11
docs-src/_includes/nav.11ty.cjs
Normal file
11
docs-src/_includes/nav.11ty.cjs
Normal file
@@ -0,0 +1,11 @@
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function ({page}) {
|
||||
return `
|
||||
<nav>
|
||||
<a href="${relative(page.url, '/')}">Home</a>
|
||||
<a href="${relative(page.url, '/examples/')}">Examples</a>
|
||||
<a href="${relative(page.url, '/api/')}">API</a>
|
||||
<a href="${relative(page.url, '/install/')}">Install</a>
|
||||
</nav>`;
|
||||
};
|
||||
37
docs-src/_includes/page.11ty.cjs
Normal file
37
docs-src/_includes/page.11ty.cjs
Normal file
@@ -0,0 +1,37 @@
|
||||
const header = require('./header.11ty.cjs');
|
||||
const footer = require('./footer.11ty.cjs');
|
||||
const nav = require('./nav.11ty.cjs');
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function (data) {
|
||||
const {title, page, content} = data;
|
||||
return `
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${title}</title>
|
||||
<link rel="stylesheet" href="${relative(page.url, '/docs.css')}">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="${relative(page.url, '/prism-okaidia.css')}" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="${relative(
|
||||
page.url,
|
||||
'/my-element.bundled.js'
|
||||
)}"></script>
|
||||
</head>
|
||||
<body>
|
||||
${header()}
|
||||
${nav(data)}
|
||||
<div id="main-wrapper">
|
||||
<main>
|
||||
${content}
|
||||
</main>
|
||||
</div>
|
||||
${footer()}
|
||||
</body>
|
||||
</html>`;
|
||||
};
|
||||
9
docs-src/_includes/relative-path.cjs
Normal file
9
docs-src/_includes/relative-path.cjs
Normal file
@@ -0,0 +1,9 @@
|
||||
const path = require('path').posix;
|
||||
|
||||
module.exports = (base, p) => {
|
||||
const relativePath = path.relative(base, p);
|
||||
if (p.endsWith('/') && !relativePath.endsWith('/') && relativePath !== '') {
|
||||
return relativePath + '/';
|
||||
}
|
||||
return relativePath;
|
||||
};
|
||||
127
docs-src/api.11ty.cjs
Normal file
127
docs-src/api.11ty.cjs
Normal file
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* This page generates its content from the custom-element.json file as read by
|
||||
* the _data/api.11tydata.js script.
|
||||
*/
|
||||
module.exports = class Docs {
|
||||
data() {
|
||||
return {
|
||||
layout: 'page.11ty.cjs',
|
||||
title: '<my-element> ⌲ Docs',
|
||||
};
|
||||
}
|
||||
|
||||
render(data) {
|
||||
const manifest = data.api['11tydata'].customElements;
|
||||
const elements = manifest.modules.reduce(
|
||||
(els, module) =>
|
||||
els.concat(
|
||||
module.declarations?.filter((dec) => dec.customElement) ?? []
|
||||
),
|
||||
[]
|
||||
);
|
||||
return `
|
||||
<h1>API</h1>
|
||||
${elements
|
||||
.map(
|
||||
(element) => `
|
||||
<h2><${element.tagName}></h2>
|
||||
<div>
|
||||
${element.description}
|
||||
</div>
|
||||
${renderTable(
|
||||
'Attributes',
|
||||
['name', 'description', 'type.text', 'default'],
|
||||
element.attributes
|
||||
)}
|
||||
${renderTable(
|
||||
'Properties',
|
||||
['name', 'attribute', 'description', 'type.text', 'default'],
|
||||
element.members.filter((m) => m.kind === 'field')
|
||||
)}
|
||||
${renderTable(
|
||||
'Methods',
|
||||
['name', 'parameters', 'description', 'return.type.text'],
|
||||
element.members
|
||||
.filter((m) => m.kind === 'method' && m.privacy !== 'private')
|
||||
.map((m) => ({
|
||||
...m,
|
||||
parameters: renderTable(
|
||||
'',
|
||||
['name', 'description', 'type.text'],
|
||||
m.parameters
|
||||
),
|
||||
}))
|
||||
)}
|
||||
${renderTable('Events', ['name', 'description'], element.events)}
|
||||
${renderTable(
|
||||
'Slots',
|
||||
[['name', '(default)'], 'description'],
|
||||
element.slots
|
||||
)}
|
||||
${renderTable(
|
||||
'CSS Shadow Parts',
|
||||
['name', 'description'],
|
||||
element.cssParts
|
||||
)}
|
||||
${renderTable(
|
||||
'CSS Custom Properties',
|
||||
['name', 'description'],
|
||||
element.cssProperties
|
||||
)}
|
||||
`
|
||||
)
|
||||
.join('')}
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads a (possibly deep) path off of an object.
|
||||
*/
|
||||
const get = (obj, path) => {
|
||||
let fallback = '';
|
||||
if (Array.isArray(path)) {
|
||||
[path, fallback] = path;
|
||||
}
|
||||
const parts = path.split('.');
|
||||
while (obj && parts.length) {
|
||||
obj = obj[parts.shift()];
|
||||
}
|
||||
return obj == null || obj === '' ? fallback : obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders a table of data, plucking the given properties from each item in
|
||||
* `data`.
|
||||
*/
|
||||
const renderTable = (name, properties, data) => {
|
||||
if (data === undefined || data.length === 0) {
|
||||
return '';
|
||||
}
|
||||
return `
|
||||
${name ? `<h3>${name}</h3>` : ''}
|
||||
<table>
|
||||
<tr>
|
||||
${properties
|
||||
.map(
|
||||
(p) =>
|
||||
`<th>${capitalize(
|
||||
(Array.isArray(p) ? p[0] : p).split('.')[0]
|
||||
)}</th>`
|
||||
)
|
||||
.join('')}
|
||||
</tr>
|
||||
${data
|
||||
.map(
|
||||
(i) => `
|
||||
<tr>
|
||||
${properties.map((p) => `<td>${get(i, p)}</td>`).join('')}
|
||||
</tr>
|
||||
`
|
||||
)
|
||||
.join('')}
|
||||
</table>
|
||||
`;
|
||||
};
|
||||
|
||||
const capitalize = (s) => s[0].toUpperCase() + s.substring(1);
|
||||
163
docs-src/docs.css
Normal file
163
docs-src/docs.css
Normal file
@@ -0,0 +1,163 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
font-family: 'Open Sans', arial, sans-serif;
|
||||
min-width: min-content;
|
||||
min-height: 100vh;
|
||||
font-size: 18px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
#main-wrapper {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 1024px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 360px;
|
||||
margin: 0;
|
||||
background: linear-gradient(0deg, rgba(9,9,121,1) 0%, rgba(0,212,255,1) 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
footer {
|
||||
width: 100%;
|
||||
min-height: 120px;
|
||||
background: gray;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 12px;
|
||||
margin-top: 64px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.6em;
|
||||
font-weight: 300;
|
||||
margin: 64px 0 12px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
width: auto;
|
||||
font-size: 2.8em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
header h2 {
|
||||
width: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
grid-template-columns: repeat(auto-fit, 240px);
|
||||
justify-content: center;
|
||||
border-bottom: 1px solid #efefef;
|
||||
}
|
||||
|
||||
nav > a {
|
||||
color: #444;
|
||||
display: block;
|
||||
flex: 1;
|
||||
font-size: 18px;
|
||||
padding: 20px 0;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav > a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
nav.collection {
|
||||
border: none;
|
||||
}
|
||||
|
||||
nav.collection > ul {
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
nav.collection > ul > li {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
nav.collection > ul > li.selected {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
nav.collection a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav.collection a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
section.columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(400px, 488px));
|
||||
grid-gap: 48px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
section.columns > div {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
section.examples {
|
||||
display: grid;
|
||||
grid-template-columns: 240px minmax(400px, 784px);
|
||||
grid-gap: 48px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
section.examples h2:first-of-type {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: solid 1px #aaa;
|
||||
padding: 4px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
34
docs-src/examples/index.md
Normal file
34
docs-src/examples/index.md
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
layout: example.11ty.cjs
|
||||
title: <my-element> ⌲ Examples ⌲ Basic
|
||||
tags: example
|
||||
name: Basic
|
||||
description: A basic example
|
||||
---
|
||||
|
||||
<style>
|
||||
my-element p {
|
||||
border: solid 1px blue;
|
||||
padding: 8px;
|
||||
}
|
||||
</style>
|
||||
<my-element>
|
||||
<p>This is child content</p>
|
||||
</my-element>
|
||||
|
||||
<h3>CSS</h3>
|
||||
|
||||
```css
|
||||
p {
|
||||
border: solid 1px blue;
|
||||
padding: 8px;
|
||||
}
|
||||
```
|
||||
|
||||
<h3>HTML</h3>
|
||||
|
||||
```html
|
||||
<my-element>
|
||||
<p>This is child content</p>
|
||||
</my-element>
|
||||
```
|
||||
15
docs-src/examples/name-property.md
Normal file
15
docs-src/examples/name-property.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
layout: example.11ty.cjs
|
||||
title: <my-element> ⌲ Examples ⌲ Name Property
|
||||
tags: example
|
||||
name: Name Property
|
||||
description: Setting the name property
|
||||
---
|
||||
|
||||
<my-element name="Earth"></my-element>
|
||||
|
||||
<h3>HTML</h3>
|
||||
|
||||
```html
|
||||
<my-element name="Earth"></my-element>
|
||||
```
|
||||
76
docs-src/index.md
Normal file
76
docs-src/index.md
Normal file
@@ -0,0 +1,76 @@
|
||||
---
|
||||
layout: page.11ty.cjs
|
||||
title: <my-element> ⌲ Home
|
||||
---
|
||||
|
||||
# <my-element>
|
||||
|
||||
`<my-element>` is an awesome element. It's a great introduction to building web components with LitElement, with nice documentation site as well.
|
||||
|
||||
## As easy as HTML
|
||||
|
||||
<section class="columns">
|
||||
<div>
|
||||
|
||||
`<my-element>` is just an HTML element. You can it anywhere you can use HTML!
|
||||
|
||||
```html
|
||||
<my-element></my-element>
|
||||
```
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<my-element></my-element>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Configure with attributes
|
||||
|
||||
<section class="columns">
|
||||
<div>
|
||||
|
||||
`<my-element>` can be configured with attributed in plain HTML.
|
||||
|
||||
```html
|
||||
<my-element name="HTML"></my-element>
|
||||
```
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<my-element name="HTML"></my-element>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Declarative rendering
|
||||
|
||||
<section class="columns">
|
||||
<div>
|
||||
|
||||
`<my-element>` can be used with declarative rendering libraries like Angular, React, Vue, and lit-html
|
||||
|
||||
```js
|
||||
import {html, render} from 'lit-html';
|
||||
|
||||
const name = 'lit-html';
|
||||
|
||||
render(
|
||||
html`
|
||||
<h2>This is a <my-element></h2>
|
||||
<my-element .name=${name}></my-element>
|
||||
`,
|
||||
document.body
|
||||
);
|
||||
```
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h2>This is a <my-element></h2>
|
||||
<my-element name="lit-html"></my-element>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
32
docs-src/install.md
Normal file
32
docs-src/install.md
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
layout: page.11ty.cjs
|
||||
title: <my-element> ⌲ Install
|
||||
---
|
||||
|
||||
# Install
|
||||
|
||||
`<my-element>` is distributed on npm, so you can install it locally or use it via npm CDNs like unpkg.com.
|
||||
|
||||
## Local Installation
|
||||
|
||||
```bash
|
||||
npm i my-element
|
||||
```
|
||||
|
||||
## CDN
|
||||
|
||||
npm CDNs like [unpkg.com]() can directly serve files that have been published to npm. This works great for standard JavaScript modules that the browser can load natively.
|
||||
|
||||
For this element to work from unpkg.com specifically, you need to include the `?module` query parameter, which tells unpkg.com to rewrite "bare" module specifiers to full URLs.
|
||||
|
||||
### HTML
|
||||
|
||||
```html
|
||||
<script type="module" src="https://unpkg.com/my-element?module"></script>
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
|
||||
```html
|
||||
import {MyElement} from 'https://unpkg.com/my-element?module';
|
||||
```
|
||||
3
docs-src/package.json
Normal file
3
docs-src/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
83
package.json
Normal file
83
package.json
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "exploRUG",
|
||||
"version": "2.0.3",
|
||||
"description": "A simple web component",
|
||||
"main": "dist/exploRUG.js",
|
||||
"module": "dist/exploRUG.js",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/exploRUG.js",
|
||||
"./react": "./dist/exploRUG.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"build:watch": "vite build --watch",
|
||||
"dev": "vite",
|
||||
"clean": "rimraf dist",
|
||||
"lint": "npm run lint:lit-analyzer && npm run lint:eslint",
|
||||
"lint:eslint": "eslint 'src/**/*.ts'",
|
||||
"lint:lit-analyzer": "lit-analyzer",
|
||||
"format": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --ignore-path ./.eslintignore --write",
|
||||
"docs": "npm run docs:clean && npm run build && npm run analyze && npm run docs:build && npm run docs:assets && npm run docs:gen",
|
||||
"docs:clean": "rimraf docs",
|
||||
"docs:gen": "eleventy --config=.eleventy.cjs",
|
||||
"docs:gen:watch": "eleventy --config=.eleventy.cjs --watch",
|
||||
"docs:build": "rollup -c --file docs/my-element.bundled.js",
|
||||
"docs:assets": "cp node_modules/prismjs/themes/prism-okaidia.css docs/",
|
||||
"docs:serve": "wds --root-dir=docs --node-resolve --watch",
|
||||
"analyze": "cem analyze --litelement --globs \"src/**/*.ts\"",
|
||||
"analyze:watch": "cem analyze --litelement --globs \"src/**/*.ts\" --watch",
|
||||
"test": "tsc && npm run test:dev && npm run test:prod",
|
||||
"test:dev": "wtr",
|
||||
"test:watch": "wtr --watch",
|
||||
"test:prod": "MODE=prod wtr",
|
||||
"test:prod:watch": "MODE=prod wtr --watch"
|
||||
},
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"lit-element",
|
||||
"typescript",
|
||||
"lit"
|
||||
],
|
||||
"author": "Google LLC",
|
||||
"license": "BSD-3-Clause",
|
||||
"peerDependencies": {
|
||||
"@lit/react": "^1.0.0",
|
||||
"lit": "^3.0.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"javascript-obfuscator": "^5.4.1",
|
||||
"lit": "^3.2.0",
|
||||
"rollup-plugin-obfuscator": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy": "^1.0.1",
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^4.0.0",
|
||||
"@custom-elements-manifest/analyzer": "^0.6.3",
|
||||
"@lit/react": "^1.0.0",
|
||||
"@open-wc/testing": "^4.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-replace": "^5.0.7",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@types/react": "^18.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
||||
"@typescript-eslint/parser": "^5.25.0",
|
||||
"@web/dev-server": "^0.1.31",
|
||||
"@web/dev-server-legacy": "^1.0.0",
|
||||
"@web/test-runner": "^0.15.0",
|
||||
"@web/test-runner-playwright": "^0.9.0",
|
||||
"@webcomponents/webcomponentsjs": "^2.8.0",
|
||||
"eslint": "^8.15.0",
|
||||
"lit-analyzer": "^1.2.1",
|
||||
"prettier": "^2.6.2",
|
||||
"react": "^18.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^4.18.0",
|
||||
"rollup-plugin-summary": "^2.0.1",
|
||||
"typescript": "~5.9.0",
|
||||
"vite": "^5.0.0",
|
||||
"vite-plugin-dts": "^3.0.0"
|
||||
},
|
||||
"customElements": "custom-elements.json"
|
||||
}
|
||||
42
rollup.config.js
Normal file
42
rollup.config.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import summary from 'rollup-plugin-summary';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
input: './Imports/exploRUG.js',
|
||||
output: {
|
||||
file: 'my-element.bundled.js',
|
||||
format: 'esm',
|
||||
},
|
||||
onwarn(warning) {
|
||||
if (warning.code !== 'THIS_IS_UNDEFINED') {
|
||||
console.error(`(!) ${warning.message}`);
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
replace({preventAssignment: false, 'Reflect.decorate': 'undefined'}),
|
||||
resolve(),
|
||||
/**
|
||||
* This minification setup serves the static site generation.
|
||||
* For bundling and minification, check the README.md file.
|
||||
*/
|
||||
terser({
|
||||
ecma: 2021,
|
||||
module: true,
|
||||
warnings: true,
|
||||
mangle: {
|
||||
properties: {
|
||||
regex: /^__/,
|
||||
},
|
||||
},
|
||||
}),
|
||||
summary(),
|
||||
],
|
||||
};
|
||||
20
src/Components/RoomView/index.ts
Normal file
20
src/Components/RoomView/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {LitElement, html, css} from 'lit';
|
||||
import {customElement, property} from 'lit/decorators.js';
|
||||
|
||||
@customElement('room-view')
|
||||
export class RoomView extends LitElement {
|
||||
static override styles = css`
|
||||
:host {
|
||||
}
|
||||
`;
|
||||
|
||||
override render() {
|
||||
return html`<h2>RoomView</h2>`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'room-view': RoomView;
|
||||
}
|
||||
}
|
||||
8
src/Components/RoomView/roomView-react.ts
Normal file
8
src/Components/RoomView/roomView-react.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import {createComponent} from '@lit/react';
|
||||
import {RoomView} from './index';
|
||||
export const RoomViewReact = createComponent({
|
||||
tagName: 'room-view',
|
||||
elementClass: RoomView,
|
||||
react: React,
|
||||
});
|
||||
2
src/Imports/exploRUG.ts
Normal file
2
src/Imports/exploRUG.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import '../Components/RoomView';
|
||||
import '../Components/RoomView/roomView-react.ts';
|
||||
12
src/index.html
Normal file
12
src/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>exploRUG Components</title>
|
||||
<script type="module" src="Imports/exploRUG.ts"></script>
|
||||
</head>
|
||||
<body>
|
||||
<room-view></room-view>
|
||||
</body>
|
||||
</html>
|
||||
34
tsconfig.json
Normal file
34
tsconfig.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"module": "es2020",
|
||||
"lib": ["es2021", "DOM", "DOM.Iterable"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"outDir": "./",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitOverride": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "ts-lit-plugin",
|
||||
"strict": true
|
||||
}
|
||||
],
|
||||
"types": ["mocha"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": []
|
||||
}
|
||||
48
vite.config.ts
Normal file
48
vite.config.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import {defineConfig} from 'vite';
|
||||
|
||||
import obfuscatorPlugin from 'rollup-plugin-obfuscator';
|
||||
|
||||
export default defineConfig({
|
||||
root: './src', // Set the root to the src directory
|
||||
build: {
|
||||
rollupOptions: {
|
||||
plugins: [
|
||||
// Obfuscate code (applied after minification)
|
||||
obfuscatorPlugin({
|
||||
options: {
|
||||
compact: true,
|
||||
controlFlowFlattening: true,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 0.75,
|
||||
},
|
||||
}),
|
||||
],
|
||||
input: './src/Imports/exploRUG.ts',
|
||||
output: {
|
||||
entryFileNames: '[name].js', // Removes hash from entry files
|
||||
chunkFileNames: '[name].js', // Removes hash from chunk files
|
||||
assetFileNames: 'assets/[name][extname]', // Removes hash from assets
|
||||
manualChunks(id) {
|
||||
if (id.includes('/Components/RoomView')) {
|
||||
return 'RoomView';
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
},
|
||||
minify: 'terser',
|
||||
terserOptions: {
|
||||
format: {
|
||||
comments: false,
|
||||
},
|
||||
},
|
||||
outDir: '../dist', // Specify the output directory
|
||||
emptyOutDir: true, // Ensure the output directory is cleared on each build
|
||||
sourcemap: false, // <-- Add this line
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
port: 5173,
|
||||
},
|
||||
});
|
||||
25
web-dev-server.config.js
Normal file
25
web-dev-server.config.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import {legacyPlugin} from '@web/dev-server-legacy';
|
||||
|
||||
const mode = process.env.MODE || 'dev';
|
||||
if (!['dev', 'prod'].includes(mode)) {
|
||||
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
|
||||
}
|
||||
|
||||
export default {
|
||||
nodeResolve: {exportConditions: mode === 'dev' ? ['development'] : []},
|
||||
preserveSymlinks: true,
|
||||
plugins: [
|
||||
legacyPlugin({
|
||||
polyfills: {
|
||||
// Manually imported in index.html file
|
||||
webcomponents: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
120
web-test-runner.config.js
Normal file
120
web-test-runner.config.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import {legacyPlugin} from '@web/dev-server-legacy';
|
||||
import {playwrightLauncher} from '@web/test-runner-playwright';
|
||||
|
||||
const mode = process.env.MODE || 'dev';
|
||||
if (!['dev', 'prod'].includes(mode)) {
|
||||
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
|
||||
}
|
||||
|
||||
// Uncomment for testing on Sauce Labs
|
||||
// Must run `npm i --save-dev @web/test-runner-saucelabs` and set
|
||||
// SAUCE_USERNAME and SAUCE_USERNAME environment variables
|
||||
// ===========
|
||||
// import {createSauceLabsLauncher} from '@web/test-runner-saucelabs';
|
||||
// const sauceLabsLauncher = createSauceLabsLauncher(
|
||||
// {
|
||||
// user: process.env.SAUCE_USERNAME,
|
||||
// key: process.env.SAUCE_USERNAME,
|
||||
// },
|
||||
// {
|
||||
// 'sauce:options': {
|
||||
// name: 'unit tests',
|
||||
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
|
||||
// process.env.GITHUB_RUN_NUMBER ?? ''
|
||||
// }`,
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
|
||||
// Uncomment for testing on BrowserStack
|
||||
// Must run `npm i --save-dev @web/test-runner-browserstack` and set
|
||||
// BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY environment variables
|
||||
// ===========
|
||||
// import {browserstackLauncher as createBrowserstackLauncher} from '@web/test-runner-browserstack';
|
||||
// const browserstackLauncher = (config) => createBrowserstackLauncher({
|
||||
// capabilities: {
|
||||
// 'browserstack.user': process.env.BROWSER_STACK_USERNAME,
|
||||
// 'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY,
|
||||
// project: 'my-element',
|
||||
// name: 'unit tests',
|
||||
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
|
||||
// process.env.GITHUB_RUN_NUMBER ?? ''
|
||||
// }`,
|
||||
// ...config,
|
||||
// }
|
||||
// });
|
||||
|
||||
const browsers = {
|
||||
// Local browser testing via playwright
|
||||
// ===========
|
||||
chromium: playwrightLauncher({product: 'chromium'}),
|
||||
firefox: playwrightLauncher({product: 'firefox'}),
|
||||
webkit: playwrightLauncher({product: 'webkit'}),
|
||||
|
||||
// Uncomment example launchers for running on Sauce Labs
|
||||
// ===========
|
||||
// chromium: sauceLabsLauncher({browserName: 'chrome', browserVersion: 'latest', platformName: 'Windows 10'}),
|
||||
// firefox: sauceLabsLauncher({browserName: 'firefox', browserVersion: 'latest', platformName: 'Windows 10'}),
|
||||
// safari: sauceLabsLauncher({browserName: 'safari', browserVersion: 'latest', platformName: 'macOS 10.15'}),
|
||||
|
||||
// Uncomment example launchers for running on Sauce Labs
|
||||
// ===========
|
||||
// chromium: browserstackLauncher({browserName: 'Chrome', os: 'Windows', os_version: '10'}),
|
||||
// firefox: browserstackLauncher({browserName: 'Firefox', os: 'Windows', os_version: '10'}),
|
||||
// safari: browserstackLauncher({browserName: 'Safari', browser_version: '14.0', os: 'OS X', os_version: 'Big Sur'}),
|
||||
};
|
||||
|
||||
// Prepend BROWSERS=x,y to `npm run test` to run a subset of browsers
|
||||
// e.g. `BROWSERS=chromium,firefox npm run test`
|
||||
const noBrowser = (b) => {
|
||||
throw new Error(`No browser configured named '${b}'; using defaults`);
|
||||
};
|
||||
let commandLineBrowsers;
|
||||
try {
|
||||
commandLineBrowsers = process.env.BROWSERS?.split(',').map(
|
||||
(b) => browsers[b] ?? noBrowser(b)
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
|
||||
// https://modern-web.dev/docs/test-runner/cli-and-configuration/
|
||||
export default {
|
||||
rootDir: '.',
|
||||
files: ['./test/**/*_test.js'],
|
||||
nodeResolve: {exportConditions: mode === 'dev' ? ['development'] : []},
|
||||
preserveSymlinks: true,
|
||||
browsers: commandLineBrowsers ?? Object.values(browsers),
|
||||
testFramework: {
|
||||
// https://mochajs.org/api/mocha
|
||||
config: {
|
||||
ui: 'tdd',
|
||||
timeout: '60000',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// Detect browsers without modules (e.g. IE11) and transform to SystemJS
|
||||
// (https://modern-web.dev/docs/dev-server/plugins/legacy/).
|
||||
legacyPlugin({
|
||||
polyfills: {
|
||||
webcomponents: true,
|
||||
// Inject lit's polyfill-support module into test files, which is required
|
||||
// for interfacing with the webcomponents polyfills
|
||||
custom: [
|
||||
{
|
||||
name: 'lit-polyfill-support',
|
||||
path: 'node_modules/lit/polyfill-support.js',
|
||||
test: "!('attachShadow' in Element.prototype) || !('getRootNode' in Element.prototype) || window.ShadyDOM && window.ShadyDOM.force",
|
||||
module: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user