Skip to content

Commit 3741707

Browse files
committed
initial commit
0 parents  commit 3741707

File tree

99 files changed

+12393
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+12393
-0
lines changed

Diff for: .eleventy.cjs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
2+
3+
module.exports = function (eleventyConfig) {
4+
eleventyConfig.addPlugin(syntaxHighlight);
5+
eleventyConfig.addPassthroughCopy('docs-src/docs.css');
6+
eleventyConfig.addPassthroughCopy('docs-src/.nojekyll');
7+
eleventyConfig.addPassthroughCopy(
8+
'node_modules/@webcomponents/webcomponentsjs'
9+
);
10+
eleventyConfig.addPassthroughCopy('node_modules/lit/polyfill-support.js');
11+
return {
12+
dir: {
13+
input: 'docs-src',
14+
output: 'docs',
15+
},
16+
templateExtensionAliases: {
17+
'11ty.cjs': '11ty.js',
18+
'11tydata.cjs': '11tydata.js',
19+
},
20+
};
21+
};

Diff for: .eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/*
2+
docs/*
3+
docs-src/*
4+
rollup-config.js
5+
custom-elements.json
6+
web-dev-server.config.js

Diff for: .eslintrc.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/eslint-recommended",
6+
"plugin:@typescript-eslint/recommended"
7+
],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": 2020,
11+
"sourceType": "module"
12+
},
13+
"plugins": ["@typescript-eslint"],
14+
"env": {
15+
"browser": true
16+
},
17+
"rules": {
18+
"no-prototype-builtins": "off",
19+
"@typescript-eslint/ban-types": "off",
20+
"@typescript-eslint/explicit-function-return-type": "off",
21+
"@typescript-eslint/explicit-module-boundary-types": "off",
22+
"@typescript-eslint/no-explicit-any": "error",
23+
"@typescript-eslint/no-empty-function": "off",
24+
"@typescript-eslint/no-non-null-assertion": "off",
25+
"@typescript-eslint/no-unused-vars": [
26+
"warn",
27+
{
28+
"argsIgnorePattern": "^_"
29+
}
30+
]
31+
},
32+
"overrides": [
33+
{
34+
"files": ["rollup.config.js", "web-test-runner.config.js"],
35+
"env": {
36+
"node": true
37+
}
38+
},
39+
{
40+
"files": [
41+
"*_test.ts",
42+
"**/custom_typings/*.ts",
43+
"packages/labs/ssr/src/test/integration/tests/**",
44+
"packages/labs/ssr/src/lib/util/parse5-utils.ts"
45+
],
46+
"rules": {
47+
"@typescript-eslint/no-explicit-any": "off"
48+
}
49+
}
50+
]
51+
}

Diff for: .gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/node_modules/
2+
/lib/
3+
/test/
4+
custom-elements.json
5+
# top level source
6+
my-element.js
7+
my-element.js.map
8+
my-element.d.ts
9+
my-element.d.ts.map
10+
# only generated for size check
11+
my-element.bundled.js
12+
13+
lwc-button.js
14+
lwc-button.js.map
15+
lwc-button.d.ts
16+
lwc-button.d.ts.map
17+
# only generated for size check
18+
lwc-button.bundled.js
19+
20+
21+
lwc-modal.js
22+
lwc-modal.js.map
23+
lwc-modal.d.ts
24+
lwc-modal.d.ts.map
25+
# only generated for size check
26+
lwc-modal.bundled.js

Diff for: .prettierrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"singleQuote": true,
5+
"bracketSpacing": false,
6+
"arrowParens": "always"
7+
}

Diff for: .vscode/extensions.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": ["runem.lit-plugin"],
7+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
8+
"unwantedRecommendations": []
9+
}

Diff for: CHANGELOG.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# @lit/lit-starter-ts
2+
3+
## 1.0.5
4+
5+
### Patch Changes
6+
7+
- [#3561](https://github.com/lit/lit/pull/3561) [`e5c254e9`](https://github.com/lit/lit/commit/e5c254e96cb5d0f770ec616332e231559325c5c5) - Update dependency `@rollup/plugin-replace`
8+
9+
## 1.0.4
10+
11+
### Patch Changes
12+
13+
- [#2922](https://github.com/lit/lit/pull/2922) [`da9db86a`](https://github.com/lit/lit/commit/da9db86a33cba710d439e254df2492f9f6dcbbee) - Update dependencies and remove unused dependencies
14+
15+
## 1.0.3
16+
17+
### Patch Changes
18+
19+
- [#2757](https://github.com/lit/lit/pull/2757) [`55841c14`](https://github.com/lit/lit/commit/55841c14f52891357dd93680d3bc5b1da6c89c8a) - Update Rollup and Rollup plugins
20+
21+
## 1.0.2
22+
23+
### Patch Changes
24+
25+
- [#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.
26+
27+
## 1.0.1
28+
29+
### Patch Changes
30+
31+
- [#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 `/`.
32+
33+
- 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)]:
34+
35+
36+
## 1.0.0
37+
38+
### Patch Changes
39+
40+
- [#2113](https://github.com/lit/lit/pull/2113) [`5b2f3642`](https://github.com/lit/lit/commit/5b2f3642ff91931b5b01f8bdd2ed98aba24f1047) - Dependency upgrades including TypeScript 4.4.2
41+
42+
- [#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.
43+
44+
- [#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.
45+
46+
- 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)]:
47+

Diff for: LICENSE

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2019 Google LLC. All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Diff for: README.md

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# LitElement TypeScript starter
2+
3+
This project includes a sample component using LitElement with TypeScript.
4+
5+
This template is generated from the `lit-starter-ts` package in [the main Lit
6+
repo](https://github.com/lit/lit). Issues and PRs for this template should be
7+
filed in that repo.
8+
9+
## Setup
10+
11+
Install dependencies:
12+
13+
```bash
14+
npm i
15+
```
16+
17+
## Build
18+
19+
This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.
20+
21+
To build the JavaScript version of your component:
22+
23+
```bash
24+
npm run build
25+
```
26+
27+
To watch files and rebuild when the files are modified, run the following command in a separate shell:
28+
29+
```bash
30+
npm run build:watch
31+
```
32+
33+
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.
34+
35+
## Testing
36+
37+
This sample uses modern-web.dev's
38+
[@web/test-runner](https://www.npmjs.com/package/@web/test-runner) for testing. See the
39+
[modern-web.dev testing documentation](https://modern-web.dev/docs/test-runner/overview) for
40+
more information.
41+
42+
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:
43+
44+
```bash
45+
npm test
46+
```
47+
48+
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:
49+
50+
```bash
51+
npm test:watch
52+
```
53+
54+
Alternatively the `test:prod` and `test:prod:watch` commands will run your tests in Lit's production mode.
55+
56+
## Dev Server
57+
58+
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.
59+
60+
To run the dev server and open the project in a new browser tab:
61+
62+
```bash
63+
npm run serve
64+
```
65+
66+
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`.
67+
68+
## Editing
69+
70+
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:
71+
72+
- Syntax highlighting
73+
- Type-checking
74+
- Code completion
75+
- Hover-over docs
76+
- Jump to definition
77+
- Linting
78+
- Quick Fixes
79+
80+
The project is setup to recommend lit-plugin to VS Code users if they don't already have it installed.
81+
82+
## Linting
83+
84+
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.
85+
86+
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`.
87+
88+
To lint the project run:
89+
90+
```bash
91+
npm run lint
92+
```
93+
94+
## Formatting
95+
96+
[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`.
97+
98+
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.
99+
100+
## Static Site
101+
102+
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 master branch](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).
103+
104+
To enable the site go to the GitHub settings and change the GitHub Pages &quot;Source&quot; setting to &quot;master branch /docs folder&quot;.</p>
105+
106+
To build the site, run:
107+
108+
```bash
109+
npm run docs
110+
```
111+
112+
To serve the site locally, run:
113+
114+
```bash
115+
npm run docs:serve
116+
```
117+
118+
To watch the site files, and re-build automatically, run:
119+
120+
```bash
121+
npm run docs:watch
122+
```
123+
124+
The site will usually be served at http://localhost:8000.
125+
126+
## Bundling and minification
127+
128+
This starter project doesn't include any build-time optimizations like bundling or minification. 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.
129+
130+
For information on building application projects that include LitElement components, see [Build for production](https://lit.dev/docs/tools/production/) on the Lit site.
131+
132+
## More information
133+
134+
See [Get started](https://lit.dev/docs/getting-started/) on the Lit site for more information.

Diff for: dev/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains HTML files containing your element for development. By running `npm run build:watch` and `npm run serve` you can edit and see changes without bundling.

Diff for: dev/index.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>&lt;my-element> Demo</title>
7+
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
8+
<script src="../node_modules/lit/polyfill-support.js"></script>
9+
<script type="module" src="../my-element.js"></script>
10+
<script type="module" src="../lwc-button.js"></script>
11+
<script type="module" src="../lwc-modal.js"></script>
12+
<style>
13+
p {
14+
border: solid 1px blue;
15+
padding: 8px;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<my-element>
21+
<p>This is child content 2</p>
22+
</my-element>
23+
24+
25+
<lwc-button on-connect="(nwcUrl) => alert('Connected')"></lwc-button>
26+
27+
</body>
28+
</html>

Diff for: docs-src/.eleventyignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore files with a leading underscore; useful for e.g. readmes in source documentation
2+
_*.md

Diff for: docs-src/.nojekyll

Whitespace-only changes.

Diff for: docs-src/_README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
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.
2+
3+
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".
4+
5+
To view the site locally, run `npm run docs:serve`.
6+
7+
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.

Diff for: docs-src/_data/api.11tydata.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
const fs = require('fs');
8+
9+
module.exports = () => {
10+
const customElements = JSON.parse(
11+
fs.readFileSync('custom-elements.json', 'utf-8')
12+
);
13+
return {
14+
customElements,
15+
};
16+
};

0 commit comments

Comments
 (0)