Merge branch 'master' into chore/add-testcases

This commit is contained in:
Pascal Schilp
2020-10-23 20:46:04 +02:00
committed by GitHub
107 changed files with 13 additions and 6534 deletions

View File

@@ -56,6 +56,7 @@
"core-js": "2.6.10",
"eslint": "^7.6.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.14.0",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-no-only-tests": "^2.4.0",

View File

@@ -1,171 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.7](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.6...@import-maps/generate@0.2.7) (2020-08-27)
**Note:** Version bump only for package @import-maps/generate
## [0.2.6](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.5...@import-maps/generate@0.2.6) (2020-04-12)
**Note:** Version bump only for package @import-maps/generate
## [0.2.5](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.4...@import-maps/generate@0.2.5) (2020-03-24)
**Note:** Version bump only for package @import-maps/generate
## [0.2.4](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.3...@import-maps/generate@0.2.4) (2020-02-09)
**Note:** Version bump only for package @import-maps/generate
## [0.2.3](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.2...@import-maps/generate@0.2.3) (2020-02-03)
### Bug Fixes
* **create:** update broken @babel/cli ([b0cb95b](https://github.com/open-wc/open-wc/commit/b0cb95b650e3aae3d04ddf1879b5eec62abe7d00))
## [0.2.2](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.1...@import-maps/generate@0.2.2) (2020-02-02)
**Note:** Version bump only for package @import-maps/generate
## [0.2.1](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.2.0...@import-maps/generate@0.2.1) (2019-11-24)
**Note:** Version bump only for package @import-maps/generate
# [0.2.0](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.9...@import-maps/generate@0.2.0) (2019-11-19)
### Features
* update to use auto compatibility of es-dev-server ([f6d085e](https://github.com/open-wc/open-wc/commit/f6d085eda5a05391d1a464b9e49222c78194b0d9))
## [0.1.9](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.8...@import-maps/generate@0.1.9) (2019-11-03)
### Bug Fixes
* align versions within the monorepo ([fa2ad9f](https://github.com/open-wc/open-wc/commit/fa2ad9f))
## [0.1.8](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.7...@import-maps/generate@0.1.8) (2019-10-25)
### Bug Fixes
* align used mocha version ([#901](https://github.com/open-wc/open-wc/issues/901)) ([3606381](https://github.com/open-wc/open-wc/commit/3606381))
## [0.1.7](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.6...@import-maps/generate@0.1.7) (2019-10-23)
**Note:** Version bump only for package @import-maps/generate
## [0.1.6](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.5...@import-maps/generate@0.1.6) (2019-08-05)
### Bug Fixes
* cleanup package.json scripts ([be6bdb5](https://github.com/open-wc/open-wc/commit/be6bdb5))
## [0.1.5](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.4...@import-maps/generate@0.1.5) (2019-07-08)
### Bug Fixes
* use file extensions for imports to support import maps ([c711b13](https://github.com/open-wc/open-wc/commit/c711b13))
## [0.1.4](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.3...@import-maps/generate@0.1.4) (2019-07-05)
### Bug Fixes
* **generate:** remove unnecessary .imports subproperty ([#549](https://github.com/open-wc/open-wc/issues/549)) ([bbd1411](https://github.com/open-wc/open-wc/commit/bbd1411))
## [0.1.3](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.2...@import-maps/generate@0.1.3) (2019-07-05)
**Note:** Version bump only for package @import-maps/generate
## [0.1.2](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.1...@import-maps/generate@0.1.2) (2019-06-27)
**Note:** Version bump only for package @import-maps/generate
## [0.1.1](https://github.com/open-wc/open-wc/compare/@import-maps/generate@0.1.0...@import-maps/generate@0.1.1) (2019-06-24)
### Bug Fixes
* **generate:** allow to run import-maps package via npx ([2452765](https://github.com/open-wc/open-wc/commit/2452765))
# 0.1.0 (2019-06-23)
### Features
* tool to generate an import map ([9287189](https://github.com/open-wc/open-wc/commit/9287189))

View File

@@ -1,177 +0,0 @@
# Generate Import Map
This will allow you to generate a flat [import-map](https://github.com/WICG/import-maps).
It allows you to fix the "nested" npm problem for front end development.
[//]: # 'AUTO INSERT HEADER PREPUBLISH'
::: warning
Currently, only yarn.lock is supported
:::
::: warning
This is still in early beta (Windows paths are not supported yet)
:::
## Features
- Generates a flat import-map
- Prompts the user when there are version conflicts that are not automatically resolvable
- Supports resolutions, overrides, and deletions via the `importMap` property in package.json
- Supports yarn workspaces (monorepos)
## Usage
Install:
```bash
yarn add --dev @import-maps/generate
```
You should generate the import map after you install dependencies by adding the script to your `postinstall` hook in `package.json`:
```json
"scripts": {
"postinstall": "generate-import-map"
}
```
If you only want to try it out once to see what it will generate you can simply do so via:
```bash
npx @import-map/generate
```
## Configuration
You can add a `importMap` key in your `package.json` file to specify overrides, deletions or resolutions.
`package.json`:
```
{
"name": "my-package",
"version": "0.0.0",
// ...
"importMap": {
"overrides": {
"imports": {},
"scopes": {}
},
"deletions": [],
"resolutions": {}
}
}
```
### Overrides
There may be times where you'll want to override certain imports. For example, if you're using the built-in `std:kv-storage` module along with `kv-storage-polyfill` for nonsupporting browsers, then `kv-storage-polyfill` will be in your lockfile. The generated import map will look like this:
```json
{
"imports": {
"kv-storage-polyfill": "/node_modules/kv-storage-polyfill/index.js",
"kv-storage-polyfill/": "/node_modules/kv-storage-polyfill/"
}
}
```
however what you actually want is to:
- use the built-in module if supported
- use the polyfill as a fallback
You can achieve that via an override in your `package.json`'s `importMap` configuration:
```json
{
"importMap": {
"overrides": {
"imports": {
"kv-storage-polyfill": ["std:kv-storage", "/node_modules/kv-storage-polyfill/index.js"]
}
},
"deletions": ["kv-storage-polyfill/"]
}
}
```
::: warning
Note that if you apply overrides, you may also need to specify deletions for the generated [package map](https://github.com/WICG/import-maps#packages-via-trailing-slashes) in the import map.
:::
Which will result in the following import map:
```json
{
"imports": {
"std:kv-storage": ["std:kv-storage", "/node_modules/kv-storage-polyfill/index.js"]
}
}
```
Overrides may be useful for:
- Polyfilling
- Fixing a dependency with a local fork
- Getting a dependency from a CDN instead
### Overriding Scopes
You can also override entire scopes:
```json
{
"importMap": {
"overrides": {
"scopes": {
"lit-html/": "/path/to/lit-html/"
}
}
}
}
```
### Deletions
You can apply deletions to the generated import map by adding a `deletions` property to your package.json:
`package.json`:
```json
{
"importMap": {
"deletions": {
"imports": ["kv-storage-polyfill"],
"scopes": ["kv-storage-polyfill/"]
}
}
}
```
### Resolutions
There may be times where you have conflicting versions of the same package in your `node_modules`. For example, one package may depend on `lit-html@0.14.0` and another on `lit-html@1.1.0`. In that case, the import map generator will prompt the user to pick a particular version to use canonically.
Alternatively, you can specify your own resolutions in your package.json.
`package.json`:
```json
{
"importMap": {
"resolutions": {
"lit-html": "1.1.0"
}
}
}
```
## Command line flags overview
### Development help
| name | type | description |
| --------- | ------ | ------------------------------------------------- |
| inject-to | string | Injects the import map to the specified html file |

View File

@@ -1,15 +0,0 @@
module.exports = {
plugins: ['babel-plugin-transform-dynamic-import'],
presets: [
[
'@babel/env',
{
targets: {
node: '10',
},
corejs: 2,
useBuiltIns: 'usage',
},
],
],
};

View File

@@ -1,51 +0,0 @@
{
"name": "@import-maps/generate",
"version": "0.2.7",
"publishConfig": {
"access": "public"
},
"description": "Generate an import map based on your production dependencies",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/open-wc/open-wc.git",
"directory": "packages/import-maps-generate"
},
"author": "open-wc",
"homepage": "https://github.com/open-wc/open-wc/tree/master/packages/import-maps-generate",
"main": "dist/generate.js",
"bin": {
"generate": "./dist/generate.js",
"generate-import-map": "./dist/generate.js"
},
"scripts": {
"build": "babel src --out-dir dist --copy-files --include-dotfiles",
"prepublishOnly": "npm run build && ../../scripts/insert-header.js",
"start": "npm run build && node ./dist/generate.js",
"test": "npm run test:node",
"test:node": "mocha --require @babel/register",
"test:watch": "onchange 'src/**/*.js' 'test/**/*.js' -- npm run test --silent"
},
"files": [
"dist"
],
"keywords": [
"import-map",
"import-maps"
],
"dependencies": {
"@yarnpkg/lockfile": "^1.1.0",
"command-line-args": "^5.0.2",
"glob": "^7.1.3",
"prompts": "^2.1.0",
"semver": "^6.1.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.11.1",
"@babel/preset-env": "^7.9.0",
"@babel/register": "^7.9.0",
"babel-plugin-transform-dynamic-import": "^2.1.0",
"onchange": "^5.2.0"
}
}

View File

@@ -1,22 +0,0 @@
import glob from 'glob';
import path from 'path';
import fs from 'fs';
export async function findPackageJson(_globString, root = process.cwd()) {
const globString = path.join(root, _globString);
return new Promise(resolve => {
const packageJsonPaths = [];
glob(globString, {}, (er, files) => {
files.forEach(wsPackagePath => {
if (fs.lstatSync(wsPackagePath).isDirectory()) {
const packageJsonPath = path.join(wsPackagePath, 'package.json');
if (fs.existsSync(packageJsonPath)) {
packageJsonPaths.push(packageJsonPath);
}
}
});
resolve(packageJsonPaths);
});
});
}

View File

@@ -1,96 +0,0 @@
import path from 'path';
import fs from 'fs';
import { findPackageJson } from './findPackageJson.js';
async function findWorkspaceParentDeps(depName, packageJson, targetPath = process.cwd()) {
const parents = [];
if (packageJson.workspaces) {
// eslint-disable-next-line no-restricted-syntax
for (const globString of packageJson.workspaces) {
// eslint-disable-next-line no-await-in-loop
const packageJsonPaths = await findPackageJson(globString, targetPath);
packageJsonPaths.forEach(packageJsonPath => {
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
const wsPackageJson = JSON.parse(packageJsonString);
if (wsPackageJson.dependencies && wsPackageJson.dependencies[depName]) {
parents.push(wsPackageJson.name);
}
});
}
}
return parents;
}
function findLocalParentDeps(depName, deps) {
const parentDeps = [];
Object.keys(deps).forEach(key => {
const dep = deps[key];
if (dep.dependencies && Object.keys(dep.dependencies).includes(depName)) {
const currentDepName = key.slice(0, key.lastIndexOf('@'));
parentDeps.push(currentDepName);
}
});
return parentDeps;
}
async function findAllParentDeps(depName, deps, packageJson, targetPath = process.cwd()) {
const parents = [
...findLocalParentDeps(depName, deps),
...(await findWorkspaceParentDeps(depName, packageJson, targetPath)),
];
return parents;
}
function readJsonFile(filePath) {
const fileContent = fs.readFileSync(filePath, 'utf-8');
return JSON.parse(fileContent);
}
export async function findPathToVersion(
depName,
version,
deps,
packageJson,
targetPath = process.cwd(),
) {
let rootVersion = '';
try {
const rootVersionPath = require.resolve(`${depName}/package.json`, {
paths: [targetPath],
});
rootVersion = readJsonFile(rootVersionPath).version;
} catch (e) {
// package could not be found
return null;
}
if (rootVersion !== version) {
const parents = await findAllParentDeps(depName, deps, packageJson, targetPath);
for (let i = 0; i < parents.length; i += 1) {
const parent = parents[i];
const parentPath = require.resolve(parent, {
paths: [targetPath],
});
const subVersionPath = require.resolve(`${depName}/package.json`, {
paths: [parentPath],
});
const { version: subVersion } = readJsonFile(subVersionPath);
if (subVersion === version) {
const result = path.relative(targetPath, require.resolve(depName, { paths: [parentPath] }));
return `/${result}`;
}
}
// non of the available versions is the required one
return null;
}
const result = path.relative(
targetPath,
require.resolve(depName, {
paths: [targetPath],
}),
);
return `/${result}`;
}

View File

@@ -1,71 +0,0 @@
import fs from 'fs';
import { findPackageJson } from './findPackageJson.js';
export async function findWorkspaceProdutionDependenies(packageJson, root = process.cwd()) {
let deps = packageJson.dependencies ? packageJson.dependencies : {};
if (packageJson.workspaces) {
// eslint-disable-next-line no-restricted-syntax
for (const globString of packageJson.workspaces) {
// eslint-disable-next-line no-await-in-loop
const packageJsonPaths = await findPackageJson(globString, root);
// eslint-disable-next-line no-loop-func
packageJsonPaths.forEach(packageJsonPath => {
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
const wsPackageJson = JSON.parse(packageJsonString);
deps = {
...deps,
...wsPackageJson.dependencies,
};
});
}
}
const finalDeps = {};
Object.keys(deps).forEach(depName => {
finalDeps[depName] = true;
});
return finalDeps;
}
/**
*
* @param {*} deps
* @param {*} packageJson
*/
export async function findProductionDependencies(deps, packageJson, targetPath = process.cwd()) {
const prodDeps = await findWorkspaceProdutionDependenies(packageJson, targetPath);
let redo = false;
do {
let requestRedo = false;
Object.keys(deps).forEach(key => {
const depName = key.slice(0, key.lastIndexOf('@'));
if (prodDeps[depName]) {
const value = deps[key];
if (value.dependencies) {
Object.keys(value.dependencies).forEach(newDep => {
if (!prodDeps[newDep]) {
prodDeps[newDep] = value.dependencies[newDep];
requestRedo = true;
}
});
}
}
});
redo = !!requestRedo;
} while (redo === true);
// we now know all production dependencies - one more pass to gather them
const result = {};
Object.keys(deps).forEach(key => {
const depName = key.slice(0, key.lastIndexOf('@'));
if (prodDeps[depName]) {
result[key] = deps[key];
}
});
return result;
}

View File

@@ -1,40 +0,0 @@
import semver from 'semver';
function findNestedDeps(deps) {
const flatDeps = {};
Object.keys(deps).forEach(dep => {
const depName = dep.slice(0, dep.lastIndexOf('@'));
const range = dep.slice(dep.lastIndexOf('@') + 1);
const depData = deps[dep];
if (!flatDeps[depName]) {
flatDeps[depName] = {
versions: [],
ranges: [],
};
}
flatDeps[depName].versions.push(depData.version);
flatDeps[depName].ranges.push(range);
});
return flatDeps;
}
function findBestVersion(ranges, versions) {
let bestVersion = false;
versions.forEach(version => {
if (ranges.every(range => semver.satisfies(version, range))) {
bestVersion = version;
}
});
return bestVersion || versions;
}
export function flattenYarnLock(deps) {
const nestedDeps = findNestedDeps(deps);
const flatDeps = {};
Object.keys(nestedDeps).forEach(dep => {
const depData = nestedDeps[dep];
flatDeps[dep] = findBestVersion(depData.ranges, depData.versions);
});
return flatDeps;
}

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import commandLineArgs from 'command-line-args';
import { generateFromYarnLock } from './generateFromYarnLock.js';
import injectToHtmlFile from './injectToHtmlFile.js';
const optionDefinitions = [{ name: 'inject-to' }];
const options = commandLineArgs(optionDefinitions);
export async function generate(targetPath = process.cwd()) {
const yarnLockString = fs.readFileSync(path.resolve(targetPath, 'yarn.lock'), 'utf-8');
const packageJsonString = fs.readFileSync(path.resolve(targetPath, 'package.json'), 'utf-8');
const packageJson = JSON.parse(packageJsonString);
const result = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
fs.writeFileSync('./import-map.json', JSON.stringify(result, null, 2));
if (options['inject-to']) {
injectToHtmlFile(options['inject-to'], JSON.stringify(result, null, 2));
}
}
generate();

View File

@@ -1,157 +0,0 @@
import * as lockfile from '@yarnpkg/lockfile';
import path from 'path';
import fs from 'fs';
import prompts from 'prompts';
import { findProductionDependencies } from './findProductionDependencies.js';
import { flattenYarnLock } from './flattenYarnLock.js';
import { findPathToVersion } from './findPathToVersion.js';
import { findPackageJson } from './findPackageJson.js';
import { postProcessImportMap } from './postProcessImportMap.js';
async function askForVersionSelection(depName, versions) {
const choices = [];
versions.forEach(version => {
choices.push({
title: version,
value: version,
});
});
const answers = await prompts([
{
type: 'select',
name: 'selectedVersion',
message: `Could not find a version of ${depName} that can satisfy all dependencies. Which version would you like to use?`,
choices,
},
]);
return answers.selectedVersion;
}
async function addWorkspaceDeps(flatResolvedDeps, packageJson, targetPath = process.cwd()) {
const deps = flatResolvedDeps;
if (packageJson.workspaces) {
// eslint-disable-next-line no-restricted-syntax
for (const globString of packageJson.workspaces) {
// eslint-disable-next-line no-await-in-loop
const packageJsonPaths = await findPackageJson(globString, targetPath);
packageJsonPaths.forEach(packageJsonPath => {
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
const wsPackageJson = JSON.parse(packageJsonString);
const depName = wsPackageJson.name;
const depPath = require.resolve(depName, {
paths: [targetPath],
});
const result = `/${path.relative(targetPath, depPath)}`;
deps[depName] = result;
});
}
}
return deps;
}
export function flatResolvedDepsToImports(deps) {
const importMap = {};
importMap.imports = {};
Object.keys(deps).forEach(depName => {
const depPath = deps[depName];
importMap.imports[depName] = depPath;
importMap.imports[`${depName}/`] = `${path.dirname(depPath)}/`;
});
return importMap;
}
function updatePackageJsonResolutions(depName, selectedVersion, packageJson, targetPath) {
// we need to do it like this as we do not want to override the order in the package.json
const newPackageJson = { ...packageJson };
newPackageJson.importMap = newPackageJson.importMap ? newPackageJson.importMap : {};
newPackageJson.importMap.resolutions = newPackageJson.importMap.resolutions
? newPackageJson.importMap.resolutions
: {};
newPackageJson.importMap.resolutions[depName] = selectedVersion;
fs.writeFileSync(
path.resolve(targetPath, 'package.json'),
JSON.stringify(newPackageJson, null, 2),
);
}
export async function resolvePathsAndConflicts(
flatDeps,
deps,
packageJson = {},
targetPath = process.cwd(),
) {
const resolvedDeps = {};
const resolveMap =
packageJson.importMap && packageJson.importMap.resolutions
? packageJson.importMap.resolutions
: {};
// eslint-disable-next-line no-restricted-syntax
for (const depName of Object.keys(flatDeps)) {
const depData = flatDeps[depName];
if (Array.isArray(depData)) {
let pathToPackage = null;
if (Object.keys(resolveMap).includes(depName)) {
// eslint-disable-next-line no-await-in-loop
pathToPackage = await findPathToVersion(
depName,
resolveMap[depName],
deps,
packageJson,
targetPath,
);
}
if (!pathToPackage) {
// eslint-disable-next-line no-await-in-loop
const selectedVersion = await askForVersionSelection(depName, depData);
// eslint-disable-next-line no-await-in-loop
pathToPackage = await findPathToVersion(
depName,
selectedVersion,
deps,
packageJson,
targetPath,
);
updatePackageJsonResolutions(depName, selectedVersion, packageJson, targetPath);
}
resolvedDeps[depName] = pathToPackage;
} else {
const depPath = require.resolve(depName, {
paths: [targetPath],
});
const result = `/${path.relative(targetPath, depPath)}`;
resolvedDeps[depName] = result;
}
}
return resolvedDeps;
}
export async function generateFromYarnLock(
yarnLockString,
packageJson,
targetPath = process.cwd(),
) {
const yarnLock = lockfile.parse(yarnLockString);
const deps = await findProductionDependencies(yarnLock.object, packageJson, targetPath);
const flatDeps = flattenYarnLock(deps);
const flatResolvedDeps = await resolvePathsAndConflicts(flatDeps, deps, packageJson, targetPath);
const flatResolvedDepsWithWorkspaceDeps = await addWorkspaceDeps(
flatResolvedDeps,
packageJson,
targetPath,
);
let imports = flatResolvedDepsToImports(flatResolvedDepsWithWorkspaceDeps);
imports = postProcessImportMap(imports, packageJson);
return imports;
}

View File

@@ -1,30 +0,0 @@
import fs from 'fs';
/**
* Injects the importMap with the following priorities
* 1. if found replaces an existing importMap
* 2. if </head> is found it adds it right before
* 3. adds it at the end of the file
*
* @param {String} filePath
* @param {String} importMap
*/
export default function injectToHtmlFile(filePath, importMap) {
let fileString = fs.readFileSync(filePath, 'utf-8');
if (fileString.includes('<script type="importmap">')) {
fileString = fileString.replace(
/<script type="importmap">(.|\n)*?<\/script>/,
`<script type="importmap">${importMap}</script>`,
);
} else if (fileString.includes('</head>')) {
fileString = fileString.replace(
'</head>',
`<script type="importmap">${importMap}</script></head>`,
);
} else {
fileString += `<script type="importmap">${importMap}</script>`;
}
fs.writeFileSync(filePath, fileString, 'utf-8');
}

View File

@@ -1,54 +0,0 @@
export function postProcessImportMap(imports, packageJson) {
const importMap = imports;
if (typeof packageJson.importMap !== 'undefined') {
if (typeof packageJson.importMap.overrides !== 'undefined') {
// override imports
if (typeof packageJson.importMap.overrides.imports !== 'undefined') {
const importOverrides = packageJson.importMap.overrides.imports;
importMap.imports = { ...importMap.imports, ...importOverrides };
}
// override scopes
if (typeof packageJson.importMap.overrides.scopes !== 'undefined') {
const { scopes } = packageJson.importMap.overrides;
importMap.scopes = { ...importMap.scopes, ...scopes };
}
}
if (typeof packageJson.importMap.deletions !== 'undefined') {
// delete imports
if (typeof packageJson.importMap.deletions.imports !== 'undefined') {
const importsToDelete = packageJson.importMap.deletions.imports;
Object.values(importsToDelete).forEach(dependency => {
delete importMap.imports[dependency];
});
}
// delete scopes
if (typeof packageJson.importMap.deletions.scopes !== 'undefined') {
const scopesToDelete = packageJson.importMap.deletions.scopes;
Object.values(scopesToDelete).forEach(dependency => {
delete importMap.scopes[dependency];
});
}
// delete imports of a scope
if (typeof packageJson.importMap.deletions.scopeImports !== 'undefined') {
const scopeImportsToDelete = packageJson.importMap.deletions.scopeImports;
Object.keys(scopeImportsToDelete).forEach(scope => {
scopeImportsToDelete[scope].forEach(item => {
delete importMap.scopes[scope][item];
});
if (Object.values(importMap.scopes[scope]).length === 0) {
delete importMap.scopes[scope];
}
});
}
}
}
return importMap;
}

View File

@@ -1,13 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,6 +0,0 @@
{
"private": true,
"dependencies": {
"lit-element": "^2.1.0"
}
}

View File

@@ -1,15 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,20 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json
!node_modules/lit-element/node_modules/
node_modules/lit-element/node_modules/*
!node_modules/lit-element/node_modules/lit-html/
node_modules/lit-element/node_modules/lit-html/*
!node_modules/lit-element/node_modules/lit-html/lit-html.js
!node_modules/lit-element/node_modules/lit-html/package.json

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,53 +0,0 @@
{
"name": "lit-html",
"version": "1.0.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.11.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,7 +0,0 @@
{
"private": true,
"dependencies": {
"lit-element": "^2.1.0",
"lit-html": "1.0.0"
}
}

View File

@@ -1,20 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.0.0.tgz#3dc3781a8ca68a9b5c2ff2a61e263662b9b2267b"
integrity sha512-oeWlpLmBW3gFl7979Wol2LKITpmKTUFNn7PnFbh6YNynF61W74l6x5WhwItAwPRSATpexaX1egNnRzlN4GOtfQ==
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,20 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json
!node_modules/lit-element/node_modules/
node_modules/lit-element/node_modules/*
!node_modules/lit-element/node_modules/lit-html/
node_modules/lit-element/node_modules/lit-html/*
!node_modules/lit-element/node_modules/lit-html/lit-html.js
!node_modules/lit-element/node_modules/lit-html/package.json

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,37 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,54 +0,0 @@
{
"name": "lit-html",
"version": "0.14.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"gen-docs": "typedoc --readme none --mode modules --ignoreCompilerErrors --excludeNotExported --excludePrivate --exclude **/*_test.ts --out ./docs/api --gaID UA-39334307-23 ./src",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.11.0",
"typedoc": "^0.13.0",
"typescript": "^3.1.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,12 +0,0 @@
{
"private": true,
"dependencies": {
"lit-element": "^2.1.0",
"lit-html": "^0.14.0"
},
"importMap": {
"resolutions": {
"lit-html": "1.1.0"
}
}
}

View File

@@ -1,20 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-0.14.0.tgz#d6830e8f55fb923b0f5824decf7da082a1d22997"
integrity sha512-+xqUPzzJGEDqb0F5DOnMXvL0jxpkKebAMlXycKZxFtzlmD+qePEmYrEUPF9XVXcc5eYBzYXTCOUcjSCod4YvgQ==
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,16 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json
!node_modules/@example/
!node_modules/b

View File

@@ -1 +0,0 @@
../../packages/a

View File

@@ -1 +0,0 @@
../packages/b

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,7 +0,0 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
]
}

View File

@@ -1,9 +0,0 @@
{
"name": "@example/a",
"version": "0.0.0",
"private": true,
"main": "./a.js",
"dependencies": {
"lit-element": "^2.0.1"
}
}

View File

@@ -1,9 +0,0 @@
{
"name": "b",
"version": "0.0.0",
"private": true,
"main": "./b.js",
"dependencies": {
"lit-html": "^1.0.0"
}
}

View File

@@ -1,15 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,23 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json
!node_modules/lit-element/node_modules/
node_modules/lit-element/node_modules/*
!node_modules/lit-element/node_modules/lit-html/
node_modules/lit-element/node_modules/lit-html/*
!node_modules/lit-element/node_modules/lit-html/lit-html.js
!node_modules/lit-element/node_modules/lit-html/package.json
!node_modules/@example/
!node_modules/b

View File

@@ -1 +0,0 @@
../../packages/a

View File

@@ -1 +0,0 @@
../packages/b

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,53 +0,0 @@
{
"name": "lit-html",
"version": "1.0.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.11.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,7 +0,0 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
]
}

View File

@@ -1,9 +0,0 @@
{
"name": "@example/a",
"version": "0.0.0",
"private": true,
"main": "./a.js",
"dependencies": {
"lit-element": "^2.0.1"
}
}

View File

@@ -1,9 +0,0 @@
{
"name": "b",
"version": "0.0.0",
"private": true,
"main": "./b.js",
"dependencies": {
"lit-html": "1.0.0"
}
}

View File

@@ -1,20 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.0.0.tgz#3dc3781a8ca68a9b5c2ff2a61e263662b9b2267b"
integrity sha512-oeWlpLmBW3gFl7979Wol2LKITpmKTUFNn7PnFbh6YNynF61W74l6x5WhwItAwPRSATpexaX1egNnRzlN4GOtfQ==
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,20 +0,0 @@
!node_modules
node_modules/*
!node_modules/lit-html/
node_modules/lit-html/*
!node_modules/lit-html/lit-html.js
!node_modules/lit-html/package.json
!node_modules/lit-element/
node_modules/lit-element/*
!node_modules/lit-element/lit-element.js
!node_modules/lit-element/package.json
packages/b/node_modules/lit-html/*
!packages/b/node_modules/lit-html/lit-html.js
!packages/b/node_modules/lit-html/package.json
!node_modules/@example/
!node_modules/b

View File

@@ -1 +0,0 @@
../packages/b

View File

@@ -1,200 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { TemplateResult } from 'lit-html';
import { render } from 'lit-html/lib/shady-render.js';
import { UpdatingElement } from './lib/updating-element.js';
export * from './lib/updating-element.js';
export * from './lib/decorators.js';
export { html, svg, TemplateResult, SVGTemplateResult } from 'lit-html/lit-html.js';
import { supportsAdoptingStyleSheets } from './lib/css-tag.js';
export * from './lib/css-tag.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for LitElement usage.
// TODO(justinfagnani): inject version number at build time
(window['litElementVersions'] || (window['litElementVersions'] = []))
.push('2.0.1');
/**
* Minimal implementation of Array.prototype.flat
* @param arr the array to flatten
* @param result the accumlated result
*/
function arrayFlat(styles, result = []) {
for (let i = 0, length = styles.length; i < length; i++) {
const value = styles[i];
if (Array.isArray(value)) {
arrayFlat(value, result);
}
else {
result.push(value);
}
}
return result;
}
/** Deeply flattens styles array. Uses native flat if available. */
const flattenStyles = (styles) => styles.flat ? styles.flat(Infinity) : arrayFlat(styles);
export class LitElement extends UpdatingElement {
/** @nocollapse */
static finalize() {
super.finalize();
// Prepare styling that is stamped at first render time. Styling
// is built from user provided `styles` or is inherited from the superclass.
this._styles =
this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?
this._getUniqueStyles() :
this._styles || [];
}
/** @nocollapse */
static _getUniqueStyles() {
// Take care not to call `this.styles` multiple times since this generates
// new CSSResults each time.
// TODO(sorvell): Since we do not cache CSSResults by input, any
// shared styles will generate new stylesheet objects, which is wasteful.
// This should be addressed when a browser ships constructable
// stylesheets.
const userStyles = this.styles;
const styles = [];
if (Array.isArray(userStyles)) {
const flatStyles = flattenStyles(userStyles);
// As a performance optimization to avoid duplicated styling that can
// occur especially when composing via subclassing, de-duplicate styles
// preserving the last item in the list. The last item is kept to
// try to preserve cascade order with the assumption that it's most
// important that last added styles override previous styles.
const styleSet = flatStyles.reduceRight((set, s) => {
set.add(s);
// on IE set.add does not return the set.
return set;
}, new Set());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles.unshift(v));
}
else if (userStyles) {
styles.push(userStyles);
}
return styles;
}
/**
* Performs element initialization. By default this calls `createRenderRoot`
* to create the element `renderRoot` node and captures any pre-set values for
* registered properties.
*/
initialize() {
super.initialize();
this.renderRoot =
this.createRenderRoot();
// Note, if renderRoot is not a shadowRoot, styles would/could apply to the
// element's getRootNode(). While this could be done, we're choosing not to
// support this now since it would require different logic around de-duping.
if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {
this.adoptStyles();
}
}
/**
* Returns the node into which the element should render and by default
* creates and returns an open shadowRoot. Implement to customize where the
* element's DOM is rendered. For example, to render into the element's
* childNodes, return `this`.
* @returns {Element|DocumentFragment} Returns a node into which to render.
*/
createRenderRoot() {
return this.attachShadow({ mode: 'open' });
}
/**
* Applies styling to the element shadowRoot using the `static get styles`
* property. Styling will apply using `shadowRoot.adoptedStyleSheets` where
* available and will fallback otherwise. When Shadow DOM is polyfilled,
* ShadyCSS scopes styles and adds them to the document. When Shadow DOM
* is available but `adoptedStyleSheets` is not, styles are appended to the
* end of the `shadowRoot` to [mimic spec
* behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
*/
adoptStyles() {
const styles = this.constructor._styles;
if (styles.length === 0) {
return;
}
// There are three separate cases here based on Shadow DOM support.
// (1) shadowRoot polyfilled: use ShadyCSS
// (2) shadowRoot.adoptedStyleSheets available: use it.
// (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after
// rendering
if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(styles.map((s) => s.cssText), this.localName);
}
else if (supportsAdoptingStyleSheets) {
this.renderRoot.adoptedStyleSheets =
styles.map((s) => s.styleSheet);
}
else {
// This must be done after rendering so the actual style insertion is done
// in `update`.
this._needsShimAdoptedStyleSheets = true;
}
}
connectedCallback() {
super.connectedCallback();
// Note, first update/render handles styleElement so we only call this if
// connected after first update.
if (this.hasUpdated && window.ShadyCSS !== undefined) {
window.ShadyCSS.styleElement(this);
}
}
/**
* Updates the element. This method reflects property values to attributes
* and calls `render` to render DOM via lit-html. Setting properties inside
* this method will *not* trigger another update.
* * @param _changedProperties Map of changed properties with old values
*/
update(changedProperties) {
super.update(changedProperties);
const templateResult = this.render();
if (templateResult instanceof TemplateResult) {
this.constructor
.render(templateResult, this.renderRoot, { scopeName: this.localName, eventContext: this });
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
// priority.
if (this._needsShimAdoptedStyleSheets) {
this._needsShimAdoptedStyleSheets = false;
this.constructor._styles.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot.appendChild(style);
});
}
}
/**
* Invoked on each update to perform rendering tasks. This method must return
* a lit-html TemplateResult. Setting properties inside this method will *not*
* trigger the element to update.
*/
render() {
}
}
/**
* Ensure this class is marked as `finalized` as an optimization ensuring
* it will not needlessly try to `finalize`.
*/
LitElement.finalized = true;
/**
* Render method used to render the lit-html TemplateResult to the element's
* DOM.
* @param {TemplateResult} Template to render.
* @param {Element|DocumentFragment} Node into which to render.
* @param {String} Element name.
* @nocollapse
*/
LitElement.render = render;
//# sourceMappingURL=lit-element.js.map

View File

@@ -1,65 +0,0 @@
{
"name": "lit-element",
"version": "2.1.0",
"description": "A simple base class for creating fast, lightweight web components",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-element",
"main": "lit-element.js",
"module": "lit-element.js",
"directories": {
"test": "test"
},
"files": [
"/lib/",
"/src/",
"!/src/demo/",
"!/src/test/",
"/lit-element.d.ts",
"/lit-element.d.ts.map",
"/lit-element.js",
"/lit-element.js.map"
],
"scripts": {
"build": "tsc",
"build:babel-test": "babel src/test/lib/decorators_test.ts --out-file test/lib/decorators-babel_test.js",
"gen-docs": "typedoc --readme docs/_api/api-readme.md --tsconfig tsconfig_apidoc.json --mode modules --theme docs/_api/theme --excludeNotExported --excludePrivate --ignoreCompilerErrors --exclude '{**/*test*,**/node_modules/**,**/test/**}' --out ./docs/api --gaID UA-39334307-23 src/**/*.ts",
"test": "npm run build && npm run build:babel-test && wct",
"checksize": "rollup -c ; rm lit-element.bundled.js",
"format": "find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepublishOnly": "npm run build",
"prepare": "npm run build",
"regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/plugin-transform-typescript": "^7.2.0",
"@types/chai": "^4.0.1",
"@types/mocha": "^5.2.4",
"@webcomponents/shadycss": "^1.8.0",
"@webcomponents/webcomponentsjs": "^2.2.3",
"chai": "^4.0.2",
"mocha": "^5.0.5",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.12.0",
"typedoc": "^0.8.0",
"typescript": "^3.2.2",
"uglify-es": "^3.3.9",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.2"
},
"typings": "lit-element.d.ts",
"dependencies": {
"lit-html": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,58 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
*
* Main lit-html module.
*
* Main exports:
*
* - [[html]]
* - [[svg]]
* - [[render]]
*
* @module lit-html
* @preferred
*/
/**
* Do not remove this comment; it keeps typedoc from misplacing the module
* docs.
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange, nothing } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
// IMPORTANT: do not change the property name or the assignment expression.
// This line will be used in regexes to search for lit-html usage.
// TODO(justinfagnani): inject version number at build time
(window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.0.0');
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,56 +0,0 @@
{
"name": "lit-html",
"version": "1.1.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"homepage": "https://lit-html.polymer-project.org/",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build",
"publish-dev": "npm test && VERSION=${npm_package_version%-*}-dev.`git rev-parse --short HEAD` && npm version --no-git-tag-version $VERSION && npm publish --tag dev"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"lit-html-benchmarks": "^0.2.0",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tachometer": "^0.4.0",
"tslint": "^5.11.0",
"typescript": "^3.4.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,12 +0,0 @@
{
"name": "root",
"private": true,
"importMap": {
"resolutions": {
"lit-html": "0.14.0"
}
},
"workspaces": [
"packages/*"
]
}

View File

@@ -1,10 +0,0 @@
{
"name": "@example/a",
"version": "0.0.0",
"private": true,
"main": "./a.js",
"dependencies": {
"lit-element": "^2.0.1",
"lit-html": "^1.0.0"
}
}

View File

@@ -1,37 +0,0 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { defaultTemplateProcessor } from './lib/default-template-processor.js';
import { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { DefaultTemplateProcessor, defaultTemplateProcessor } from './lib/default-template-processor.js';
export { directive, isDirective } from './lib/directive.js';
// TODO(justinfagnani): remove line when we get NodePart moving methods
export { removeNodes, reparentNodes } from './lib/dom.js';
export { noChange } from './lib/part.js';
export { AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isPrimitive, NodePart, PropertyCommitter, PropertyPart } from './lib/parts.js';
export { parts, render } from './lib/render.js';
export { templateCaches, templateFactory } from './lib/template-factory.js';
export { TemplateInstance } from './lib/template-instance.js';
export { SVGTemplateResult, TemplateResult } from './lib/template-result.js';
export { createMarker, isTemplatePartActive, Template } from './lib/template.js';
/**
* Interprets a template literal as an HTML template that can efficiently
* render to and update a container.
*/
export const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
/**
* Interprets a template literal as an SVG template that can efficiently
* render to and update a container.
*/
export const svg = (strings, ...values) => new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);
//# sourceMappingURL=lit-html.js.map

View File

@@ -1,54 +0,0 @@
{
"name": "lit-html",
"version": "0.14.0",
"description": "HTML template literals in JavaScript",
"license": "BSD-3-Clause",
"repository": "Polymer/lit-html",
"main": "lit-html.js",
"module": "lit-html.js",
"directories": {
"test": "test"
},
"files": [
"/lit-html.js",
"/lit-html.js.map",
"/lit-html.d.ts",
"/lit-html.d.ts.map",
"/lib/",
"/directives/",
"/polyfills",
"/src/",
"!/src/test/"
],
"scripts": {
"build": "tsc",
"checksize": "rollup -c ; cat lit-html.bundled.js | gzip -9 | wc -c ; rm lit-html.bundled.js",
"gen-docs": "typedoc --readme none --mode modules --ignoreCompilerErrors --excludeNotExported --excludePrivate --exclude **/*_test.ts --out ./docs/api --gaID UA-39334307-23 ./src",
"test": "npm run build && npm run lint && wct --npm",
"quicktest": "wct -l chrome -p --npm",
"format": "clang-format --version; find src test | grep '\\.js$\\|\\.ts$' | xargs clang-format --style=file -i",
"lint": "tslint --project ./",
"prepare": "npm run build"
},
"author": "The Polymer Authors",
"devDependencies": {
"@types/chai": "^4.1.0",
"@types/mocha": "^5.2.0",
"@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.4",
"chai": "^4.1.2",
"clang-format": "^1.2.4",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-terser": "^1.0.1",
"tslint": "^5.11.0",
"typedoc": "^0.13.0",
"typescript": "^3.1.1",
"uglify-es": "^3.3.5",
"wct-mocha": "^1.0.0",
"web-component-tester": "^6.9.0"
},
"typings": "lit-html.d.ts",
"dependencies": {}
}

View File

@@ -1,9 +0,0 @@
{
"name": "b",
"version": "0.0.0",
"private": true,
"main": "./b.js",
"dependencies": {
"lit-html": "^0.14.0"
}
}

View File

@@ -1,20 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lit-element@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.1.0.tgz#85bc3f1da0227f4b13de8a1be978229b9fa327e9"
integrity sha512-0z/KHm1xZweivfOVRr8AKR06+D3k02u15m9s4jkuRdnGe5wfmEwePzrQQBsSZNILdnfJvfo3TJOeGhBCVZaPbw==
dependencies:
lit-html "^1.0.0"
lit-html@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-0.14.0.tgz#d6830e8f55fb923b0f5824decf7da082a1d22997"
integrity sha512-+xqUPzzJGEDqb0F5DOnMXvL0jxpkKebAMlXycKZxFtzlmD+qePEmYrEUPF9XVXcc5eYBzYXTCOUcjSCod4YvgQ==
lit-html@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.0.tgz#6951fb717fb48fe34d915ae163448a04da321562"
integrity sha512-ZDJHpJi09yknMpjwPI8fuSl5sUG7+pF+eE5WciFtgyX7zebvgMDBgSLq4knXa7grxM00RkQ7PBd7UZQiruA78Q==

View File

@@ -1,26 +0,0 @@
export const indexHtml = `<html>
<head>
<title>foo</title>
</head>
<body>
bar
</body>
</html>
`;
export const indexHtmlWithImportMap = `<html>
<head>
<title>foo</title>
<script type="importmap">
{
"imports": {
"a": "a"
}
}
</script>
</head>
<body>
bar
</body>
</html>
`;

View File

@@ -1,15 +0,0 @@
import chai from 'chai';
import { findPackageJson } from '../src/findPackageJson.js';
const { expect } = chai;
describe('findPackageJson', () => {
it('returns a list of pathes to package.jsons', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspace/`;
const wsDeps = await findPackageJson('packages/*', targetPath);
expect(wsDeps).to.deep.equal([
`${targetPath}packages/a/package.json`,
`${targetPath}packages/b/package.json`,
]);
});
});

View File

@@ -1,58 +0,0 @@
import chai from 'chai';
import fs from 'fs';
import * as lockfile from '@yarnpkg/lockfile';
import { findPathToVersion } from '../src/findPathToVersion.js';
const { expect } = chai;
describe('findPathToVersion', () => {
it('returns the path to a specific nested version', async () => {
const targetPath = `${__dirname}/assets/exampleNestedResolution/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const yarnLock = lockfile.parse(yarnLockString);
const path = await findPathToVersion('lit-html', '1.1.0', yarnLock.object, {}, targetPath);
expect(path).to.equal('/node_modules/lit-element/node_modules/lit-html/lit-html.js');
});
it('returns null if package or version could not be found', async () => {
const targetPath = `${__dirname}/assets/exampleNestedResolution/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const yarnLock = lockfile.parse(yarnLockString);
const wrongVersion = await findPathToVersion(
'lit-html',
'10.0.0',
yarnLock.object,
{}, //
targetPath,
);
expect(wrongVersion).to.be.null;
const pathNonExistingVersion = await findPathToVersion(
'lit-html2',
'1.0.0',
yarnLock.object,
{},
targetPath,
);
expect(pathNonExistingVersion).to.be.null;
});
});
describe('findPathToVersion in a workspace', () => {
it('returns the path to a specific nested version', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspaceNestedResolution/`;
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const yarnLock = lockfile.parse(yarnLockString);
const path = await findPathToVersion(
'lit-html', //
'0.14.0',
yarnLock.object,
packageJson,
targetPath,
);
expect(path).to.equal('/packages/b/node_modules/lit-html/lit-html.js');
});
});

View File

@@ -1,74 +0,0 @@
import chai from 'chai';
import fs from 'fs';
import {
findProductionDependencies,
findWorkspaceProdutionDependenies,
} from '../src/findProductionDependencies.js';
const { expect } = chai;
describe('findProductionDependencies', () => {
it('returns only production dependencies', async () => {
const packageJson = {
dependencies: {
'test-wc-card': '^0.0.3',
},
};
const graph = {
'lit-element@^2.0.1': {
version: '2.1.0',
dependencies: {
'lit-html': '^1.0.0',
},
},
'lit-html@1.0.0': {
version: '1.0.0',
},
'test-wc-card@^0.0.3': {
version: '0.0.3',
dependencies: {
'lit-element': '^2.0.1',
},
},
'type-detect@^4.0.0': {
version: '4.0.8',
},
};
const deps = await findProductionDependencies(graph, {
dependencies: packageJson.dependencies,
});
expect(deps).to.deep.equal({
'lit-element@^2.0.1': {
version: '2.1.0',
dependencies: {
'lit-html': '^1.0.0',
},
},
'lit-html@1.0.0': {
version: '1.0.0',
},
'test-wc-card@^0.0.3': {
version: '0.0.3',
dependencies: {
'lit-element': '^2.0.1',
},
},
});
});
});
describe('findWorkspaceProdutionDependenies', () => {
it('returns an object with all production dependencies', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspace/`;
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const wsDeps = await findWorkspaceProdutionDependenies(packageJson, targetPath);
expect(wsDeps).to.deep.equal({
'lit-html': true,
'lit-element': true,
});
});
});

View File

@@ -1,40 +0,0 @@
import chai from 'chai';
import { flattenYarnLock } from '../src/flattenYarnLock.js';
const { expect } = chai;
describe('flattenYarnLock', () => {
it('flattens yarn.lock data to a simple name: version object', async () => {
const yarnLock = {
'lit-html@1.0.0': {
version: '1.0.0',
},
'lit-html@^1.0.0': {
version: '1.1.0',
},
};
const flattened = flattenYarnLock(yarnLock);
expect(flattened).to.deep.equal({
'lit-html': '1.0.0',
});
});
it('returns an array as versions if no suitable version is found', async () => {
const yarnLock = {
'lit-html@^1.0.0': {
version: '1.0.0',
},
'lit-html@^2.0.0': {
version: '2.0.0',
},
};
const flattened = flattenYarnLock(yarnLock);
expect(flattened).to.deep.equal({
'lit-html': ['1.0.0', '2.0.0'],
});
});
});

View File

@@ -1,182 +0,0 @@
import chai from 'chai';
import fs from 'fs';
import {
generateFromYarnLock,
resolvePathsAndConflicts,
flatResolvedDepsToImports,
} from '../src/generateFromYarnLock.js';
const { expect } = chai;
describe('resolvePathsAndConflicts', () => {
it('will resolve conflicts via a resolution map', async () => {
const flattened = await resolvePathsAndConflicts(
{
'lit-html': ['0.14.0', '1.1.0'],
},
{
'lit-element@^2.0.0': {
version: '2.1.0',
dependencies: {
'lit-html': '^1.0.0',
},
},
'lit-html@^0.14.0': {
version: '0.14.0',
},
'lit-html@^1.0.0': {
version: '1.1.0',
},
},
{
importMap: {
resolutions: {
'lit-html': '1.1.0',
},
},
},
`${__dirname}/assets/exampleNestedResolution/`,
);
expect(flattened).to.deep.equal({
'lit-html': '/node_modules/lit-element/node_modules/lit-html/lit-html.js',
});
});
});
describe('flatResolvedDepsToImports', () => {
it('converts resolved package entry files to imports for subfiles', async () => {
const flatResolvedDeps = {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-html': '/node_modules/lit-element/node_modules/lit-html/lit-html.js',
};
const importMap = flatResolvedDepsToImports(flatResolvedDeps);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-element/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-element/node_modules/lit-html/',
},
});
});
});
describe('generateFromYarnLock', () => {
it('generates an import map for a flat yarn.lock file', async () => {
const targetPath = `${__dirname}/assets/example/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-html/',
},
});
});
it('generates a flat import map for nested dependencies if possible', async () => {
const targetPath = `${__dirname}/assets/exampleNested/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-html/',
},
});
});
it('generates a flat import map for nested dependencies if resolutions are provided', async () => {
const targetPath = `${__dirname}/assets/exampleNestedResolution/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-element/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-element/node_modules/lit-html/',
},
});
});
});
describe('generateFromYarnLock supports yarn workspaces', () => {
it('generates a flat import map by default', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspace/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-html/',
'@example/a': '/packages/a/a.js',
'@example/a/': '/packages/a/',
b: '/packages/b/b.js',
'b/': '/packages/b/',
},
});
});
it('generates a flat import map for semver possible nested dependencies', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspaceNested/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/node_modules/lit-html/lit-html.js',
'lit-html/': '/node_modules/lit-html/',
'@example/a': '/packages/a/a.js',
'@example/a/': '/packages/a/',
b: '/packages/b/b.js',
'b/': '/packages/b/',
},
});
});
it('generates a flat import map for semver impossible nested dependencies with a resolution', async () => {
const targetPath = `${__dirname}/assets/exampleWorkspaceNestedResolution/`;
const yarnLockString = fs.readFileSync(`${targetPath}/yarn.lock`, 'utf-8');
const packageJson = JSON.parse(fs.readFileSync(`${targetPath}/package.json`, 'utf-8'));
const importMap = await generateFromYarnLock(yarnLockString, packageJson, targetPath);
expect(importMap).to.deep.equal({
imports: {
'lit-element': '/node_modules/lit-element/lit-element.js',
'lit-element/': '/node_modules/lit-element/',
'lit-html': '/packages/b/node_modules/lit-html/lit-html.js',
'lit-html/': '/packages/b/node_modules/lit-html/',
'@example/a': '/packages/a/a.js',
'@example/a/': '/packages/a/',
b: '/packages/b/b.js',
'b/': '/packages/b/',
},
});
});
});

View File

@@ -1,45 +0,0 @@
import chai from 'chai';
import fs from 'fs';
import { indexHtml, indexHtmlWithImportMap } from './assets/injectToHtmlFile/utils.js';
import injectToHtmlFile from '../src/injectToHtmlFile.js';
const { expect } = chai;
describe('injectToHtmlFile', () => {
const importMap = JSON.stringify({ imports: { foo: 'bar' } });
it('injects an importMap before </head> in a file', () => {
const filePath = `${__dirname}/assets/injectToHtmlFile/index.html`;
fs.writeFileSync(filePath, indexHtml, 'utf-8');
injectToHtmlFile(filePath, importMap);
const result = fs.readFileSync(filePath).toString();
const importMapFromHtml = result.match(/<script type="importmap">(.|\n)*?<\/script>/)[0];
expect(importMapFromHtml).to.equal(`<script type="importmap">${importMap}</script>`);
fs.unlinkSync(filePath);
});
it('replaces an importMap if one already exists', () => {
const filePath = `${__dirname}/assets/injectToHtmlFile/indexWithImportMap.html`;
fs.writeFileSync(filePath, indexHtmlWithImportMap, 'utf-8');
injectToHtmlFile(filePath, importMap);
const result = fs.readFileSync(filePath).toString();
const importMapFromHtml = result.match(/<script type="importmap">(.|\n)*?<\/script>/)[0];
expect(importMapFromHtml).to.equal(`<script type="importmap">${importMap}</script>`);
fs.unlinkSync(filePath);
});
it('injects an at the end of the file if no </head> or existing importMap is found', () => {
const filePath = `${__dirname}/assets/injectToHtmlFile/index.html`;
fs.writeFileSync(filePath, '', 'utf-8');
injectToHtmlFile(filePath, importMap);
const result = fs.readFileSync(filePath).toString();
expect(result).to.equal(`<script type="importmap">${importMap}</script>`);
fs.unlinkSync(filePath);
});
});

View File

@@ -1,202 +0,0 @@
import chai from 'chai';
import { postProcessImportMap } from '../src/postProcessImportMap.js';
const { expect } = chai;
describe('postProcessImportMap', () => {
it('can override imports', () => {
const importMap = {
imports: {
a: '/path/to/a/a.js',
b: '/node_modules/kvs-polyfill/index.mjs',
},
};
const packageJson = {
importMap: {
overrides: {
imports: {
a: '/newPath/patchIt.js',
b: ['std:kv-storage', '/node_modules/kvs-polyfill/index.mjs'],
},
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
imports: {
a: '/newPath/patchIt.js',
b: ['std:kv-storage', '/node_modules/kvs-polyfill/index.mjs'],
},
});
});
it('can override scopes', () => {
const importMap = {
imports: {
a: '/path/to/a/a.js',
b: '/node_modules/kvs-polyfill/index.mjs',
},
scopes: {
'/scope2/': {
a: '/a-2.js',
},
'/scope2/scope3/': {
a: '/a-3.js',
},
},
};
// 1. everyone uses the polyfill
// 2. urls within `/scope2/*` use built in with fallback to polyfill
// 3. urls within `/scope2/scope3/*` forced to use built in
const packageJson = {
importMap: {
overrides: {
scopes: {
'/scope2/': {
b: ['std:kv-storage', '/node_modules/kvs-polyfill/index.mjs'],
},
'/scope2/scope3/': {
a: '/a-3-override.js',
b: 'std:kv-storage',
},
},
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
imports: {
a: '/path/to/a/a.js',
b: '/node_modules/kvs-polyfill/index.mjs',
},
scopes: {
'/scope2/': {
b: ['std:kv-storage', '/node_modules/kvs-polyfill/index.mjs'],
},
'/scope2/scope3/': {
a: '/a-3-override.js',
b: 'std:kv-storage',
},
},
});
});
it('can delete imports', () => {
const importMap = {
imports: {
a: '/path/to/a/a.js',
'a/': '/path/to/a/',
b: ['std:kv-storage', '/node_modules/kvs-polyfill/index.mjs'],
c: '/path/to/c/c.js',
},
};
const packageJson = {
importMap: {
deletions: {
imports: ['a', 'a/', 'b'],
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
imports: {
c: '/path/to/c/c.js',
},
});
});
it('can delete complete scopes', () => {
const importMap = {
scopes: {
'/scope2/': {
a: '/a-2.js',
},
'/scope2/scope3/': {
a: '/a-3.js',
},
},
};
const packageJson = {
importMap: {
deletions: {
scopes: ['/scope2/scope3/'],
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
scopes: {
'/scope2/': {
a: '/a-2.js',
},
},
});
});
it('can delete imports of a scope', () => {
const importMap = {
scopes: {
'/scope2/': {
a: '/a-2.js',
b: '/b-2.js',
},
'/scope2/scope3/': {
a: '/a-3.js',
b: '/b-3.js',
},
},
};
const packageJson = {
importMap: {
deletions: {
scopeImports: {
'/scope2/': ['a'],
'/scope2/scope3/': ['b'],
},
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
scopes: {
'/scope2/': {
b: '/b-2.js',
},
'/scope2/scope3/': {
a: '/a-3.js',
},
},
});
});
it('cleans up empty scopes after if imports are deleted', () => {
const importMap = {
scopes: {
'/scope2/': {
a: '/a-2.js',
b: '/b-2.js',
},
'/scope2/scope3/': {
a: '/a-3.js',
},
},
};
const packageJson = {
importMap: {
deletions: {
scopeImports: {
'/scope2/': ['a', 'b'],
},
},
},
};
expect(postProcessImportMap(importMap, packageJson)).to.deep.equal({
scopes: {
'/scope2/scope3/': {
a: '/a-3.js',
},
},
});
});
});

View File

@@ -1,170 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.1.0](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.14...@open-wc/prettier-config@1.1.0) (2020-04-20)
### Features
* **prettier-config:** update to prettier v2 ([908013c](https://github.com/open-wc/open-wc/commit/908013cd3090daa551bc5eccaa1eae4032257262))
## [0.1.14](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.13...@open-wc/prettier-config@0.1.14) (2020-02-09)
### Bug Fixes
* update linting docu to updates in package.json ([e58015c](https://github.com/open-wc/open-wc/commit/e58015cddd6f72650d99059900f3142d2a4b0dc9))
## [0.1.13](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.12...@open-wc/prettier-config@0.1.13) (2019-12-08)
**Note:** Version bump only for package @open-wc/prettier-config
## [0.1.12](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.11...@open-wc/prettier-config@0.1.12) (2019-11-03)
### Bug Fixes
* align versions ([42f05f4](https://github.com/open-wc/open-wc/commit/42f05f4))
## [0.1.11](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.10...@open-wc/prettier-config@0.1.11) (2019-10-23)
### Bug Fixes
* add package keywords ([#859](https://github.com/open-wc/open-wc/issues/859)) ([cd78405](https://github.com/open-wc/open-wc/commit/cd78405))
## [0.1.10](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.9...@open-wc/prettier-config@0.1.10) (2019-04-14)
### Bug Fixes
* update generator usage ([5d284d4](https://github.com/open-wc/open-wc/commit/5d284d4))
## [0.1.9](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.8...@open-wc/prettier-config@0.1.9) (2019-03-13)
### Bug Fixes
* **create:** generated prettier scripts should work on windows ([438a319](https://github.com/open-wc/open-wc/commit/438a319))
## [0.1.8](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.7...@open-wc/prettier-config@0.1.8) (2019-03-08)
**Note:** Version bump only for package @open-wc/prettier-config
## [0.1.7](https://github.com/open-wc/open-wc/compare/@open-wc/prettier-config@0.1.6...@open-wc/prettier-config@0.1.7) (2019-02-16)
### Bug Fixes
* update package repository fields with monorepo details ([cb1acb7](https://github.com/open-wc/open-wc/commit/cb1acb7))
## [0.1.6](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.5...@open-wc/prettier-config@0.1.6) (2019-02-02)
### Bug Fixes
* unify npm readme header for all open-wc packages ([1bac939](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/1bac939))
## [0.1.5](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.4...@open-wc/prettier-config@0.1.5) (2019-01-26)
### Bug Fixes
* align all open-wc readme headers ([b589429](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/b589429))
## [0.1.4](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.3...@open-wc/prettier-config@0.1.4) (2019-01-20)
### Bug Fixes
* refactor generators ([1dab1f4](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/1dab1f4))
## [0.1.3](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.2...@open-wc/prettier-config@0.1.3) (2019-01-19)
### Bug Fixes
* restructure menu and improve docu ([dd37e22](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/dd37e22))
## [0.1.2](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.1...@open-wc/prettier-config@0.1.2) (2019-01-16)
### Bug Fixes
* improve documentation ([4f5472f](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/4f5472f))
## [0.1.1](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/compare/@open-wc/prettier-config@0.1.0...@open-wc/prettier-config@0.1.1) (2018-12-20)
### Bug Fixes
* linting generators & documentation ([5c29f7a](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/5c29f7a))
# 0.1.0 (2018-12-12)
### Features
* **prettier-config:** add prettier and eslint-config-prettier ([c0c359a](https://github.com/open-wc/open-wc/tree/master/packages/prettier-config/commit/c0c359a))

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 open-wc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,61 +0,0 @@
# Linting Prettier
Use [Prettier](https://prettier.io) to format your JS, CSS and HTML code.
> :Warning: this package is deprecated. We recommend using prettier v2 with the recommend config instead.
## Setup
```bash
npm init @open-wc
# Upgrade > Linting
```
## Manual
- Install `@open-wc/prettier-config`
```bash
npm add --save-dev @open-wc/prettier-config
```
- Adjust your package.json with the following
```js
"scripts": {
"lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore",
"format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore"
},
"devDependencies": {
"@open-wc/prettier-config": "^0.1.10"
},
"eslintConfig": {
"extends": [
"eslint-config-prettier"
]
},
"prettier": "@open-wc/prettier-config"
```
## What you get
- Apply formatting to JS files
- Apply formatting to HTML inside of `html` tagged template literals used by [lit-html](https://github.com/Polymer/lit-html)
- Apply formatting to CSS inside of `css` tagged template literals used by [lit-element](https://lit-element.polymer-project.org/guide/styles#static-styles)
- Integration with ESLint to prevent potentially conflicting rules
## Usage
Run:
- `npm run lint:prettier` to check if your files are correctly formatted
- `npm run format:prettier` to auto format your files
## Linting Error Examples
```bash
$ npm run lint:prettier
test/set-card.test.js
test/set-game.test.js
↑↑ these files are not prettier formatted ↑↑
```
Simply run `npm run format:prettier` to format your files automatically.

View File

@@ -1,30 +0,0 @@
{
"name": "@open-wc/prettier-config",
"version": "1.1.0",
"publishConfig": {
"access": "public"
},
"description": "Prettier config following open-wc recommendations",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/open-wc/open-wc.git",
"directory": "packages/prettier-config"
},
"author": "open-wc",
"homepage": "https://github.com/open-wc/open-wc/tree/master/packages/prettier-config",
"main": "prettier.config.js",
"scripts": {
"prepublishOnly": "../../scripts/insert-header.js"
},
"keywords": [
"prettier",
"linting",
"formatting",
"config"
],
"dependencies": {
"eslint-config-prettier": "^3.3.0",
"prettier": "^2.0.0"
}
}

View File

@@ -1,11 +0,0 @@
module.exports = {
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: 'avoid',
};

View File

@@ -1,583 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.12.8](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.7...rollup-plugin-index-html@1.12.8) (2020-10-11)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.7](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.6...rollup-plugin-index-html@1.12.7) (2020-09-25)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.6](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.5...rollup-plugin-index-html@1.12.6) (2020-08-27)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.5](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.4...rollup-plugin-index-html@1.12.5) (2020-08-19)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.3...rollup-plugin-index-html@1.12.4) (2020-05-13)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.2...rollup-plugin-index-html@1.12.3) (2020-05-07)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.1...rollup-plugin-index-html@1.12.2) (2020-05-07)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.12.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.12.0...rollup-plugin-index-html@1.12.1) (2020-05-05)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.12.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.11.1...rollup-plugin-index-html@1.12.0) (2020-04-28)
### Features
* **resolve:** update to latest proposal specs (only mapping and scopes) ([86ab538](https://github.com/open-wc/open-wc/commit/86ab53844e74e16982aa221b1f8520bc6598e6e0))
## [1.11.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.11.0...rollup-plugin-index-html@1.11.1) (2020-04-20)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.11.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.6...rollup-plugin-index-html@1.11.0) (2020-04-14)
### Features
* **rollup-plugin-index-html:** deprecate plugin ([10b8681](https://github.com/open-wc/open-wc/commit/10b8681b99bfc333dc92868caea59f9140c060fe))
## [1.10.6](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.5...rollup-plugin-index-html@1.10.6) (2020-04-12)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.10.5](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.4...rollup-plugin-index-html@1.10.5) (2020-04-05)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.10.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.3...rollup-plugin-index-html@1.10.4) (2020-03-24)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.10.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.2...rollup-plugin-index-html@1.10.3) (2020-03-11)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.10.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.1...rollup-plugin-index-html@1.10.2) (2020-03-10)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.10.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.10.0...rollup-plugin-index-html@1.10.1) (2020-03-06)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.10.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.9.3...rollup-plugin-index-html@1.10.0) (2020-02-29)
### Features
* **rollup-plugin-html:** first release ([9acb29a](https://github.com/open-wc/open-wc/commit/9acb29ac84b0ef7e2b06c57043c9d2c76d5a29c0))
## [1.9.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.9.2...rollup-plugin-index-html@1.9.3) (2020-02-23)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.9.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.9.1...rollup-plugin-index-html@1.9.2) (2020-02-10)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.9.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.9.0...rollup-plugin-index-html@1.9.1) (2020-02-09)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.9.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.8.2...rollup-plugin-index-html@1.9.0) (2020-02-06)
### Features
* **polyfills-loader:** add shady css scoped polyfill ([3c0bc88](https://github.com/open-wc/open-wc/commit/3c0bc88f0e67806abbb901d689b01c565261b6e0))
## [1.8.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.8.1...rollup-plugin-index-html@1.8.2) (2020-02-03)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.8.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.8.0...rollup-plugin-index-html@1.8.1) (2020-02-02)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.8.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.5...rollup-plugin-index-html@1.8.0) (2020-01-31)
### Bug Fixes
* skip brooken published versions ([25d21de](https://github.com/open-wc/open-wc/commit/25d21def522f22f98fc8c71b4c055617089c0e23))
### Features
* **polyfills-loader:** add polyfills loader ([249fee8](https://github.com/open-wc/open-wc/commit/249fee8a64982021eb2e1ad1937f3c08a4abc3c5))
## [1.7.5](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.4...rollup-plugin-index-html@1.7.5) (2019-12-09)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.7.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.3...rollup-plugin-index-html@1.7.4) (2019-12-05)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.7.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.2...rollup-plugin-index-html@1.7.3) (2019-12-01)
### Bug Fixes
* **building-utils:** update snapshots ([5fc118a](https://github.com/open-wc/open-wc/commit/5fc118af6c19412cc7f782e73e6006234aa892d0))
## [1.7.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.1...rollup-plugin-index-html@1.7.2) (2019-11-24)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.7.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.7.0...rollup-plugin-index-html@1.7.1) (2019-11-20)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.7.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.6.0...rollup-plugin-index-html@1.7.0) (2019-11-19)
### Features
* **rollup-plugin-index-html:** configurable indexFilename ([d121e06](https://github.com/open-wc/open-wc/commit/d121e06b58f22880409621999783748606541cba))
# [1.6.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.9...rollup-plugin-index-html@1.6.0) (2019-11-19)
### Features
* update to use auto compatibility of es-dev-server ([f6d085e](https://github.com/open-wc/open-wc/commit/f6d085eda5a05391d1a464b9e49222c78194b0d9))
## [1.5.9](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.8...rollup-plugin-index-html@1.5.9) (2019-11-03)
### Bug Fixes
* align versions within the monorepo ([fa2ad9f](https://github.com/open-wc/open-wc/commit/fa2ad9f))
## [1.5.8](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.7...rollup-plugin-index-html@1.5.8) (2019-10-25)
### Bug Fixes
* align used mocha version ([#901](https://github.com/open-wc/open-wc/issues/901)) ([3606381](https://github.com/open-wc/open-wc/commit/3606381))
## [1.5.7](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.6...rollup-plugin-index-html@1.5.7) (2019-10-23)
### Bug Fixes
* add package keywords ([#859](https://github.com/open-wc/open-wc/issues/859)) ([cd78405](https://github.com/open-wc/open-wc/commit/cd78405))
## [1.5.6](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.5...rollup-plugin-index-html@1.5.6) (2019-10-22)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.5.5](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.4...rollup-plugin-index-html@1.5.5) (2019-09-27)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.5.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.3...rollup-plugin-index-html@1.5.4) (2019-09-22)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.5.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.2...rollup-plugin-index-html@1.5.3) (2019-09-11)
### Bug Fixes
* **building-utils:** resolve dynamic imports ([#795](https://github.com/open-wc/open-wc/issues/795)) ([9ac1a4a](https://github.com/open-wc/open-wc/commit/9ac1a4a))
## [1.5.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.1...rollup-plugin-index-html@1.5.2) (2019-08-21)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.5.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.5.0...rollup-plugin-index-html@1.5.1) (2019-08-20)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.5.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.12...rollup-plugin-index-html@1.5.0) (2019-08-14)
### Features
* **eslint-config:** update dependencies ([52909e8](https://github.com/open-wc/open-wc/commit/52909e8))
## [1.4.12](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.11...rollup-plugin-index-html@1.4.12) (2019-08-13)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.11](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.10...rollup-plugin-index-html@1.4.11) (2019-08-13)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.10](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.9...rollup-plugin-index-html@1.4.10) (2019-08-05)
### Bug Fixes
* cleanup package.json scripts ([be6bdb5](https://github.com/open-wc/open-wc/commit/be6bdb5))
## [1.4.9](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.8...rollup-plugin-index-html@1.4.9) (2019-08-04)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.8](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.7...rollup-plugin-index-html@1.4.8) (2019-07-26)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.7](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.6...rollup-plugin-index-html@1.4.7) (2019-07-24)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.6](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.5...rollup-plugin-index-html@1.4.6) (2019-07-23)
### Bug Fixes
* **rollup-plugin-index-html:** linting error for console.log use ([#621](https://github.com/open-wc/open-wc/issues/621)) ([49fd5ac](https://github.com/open-wc/open-wc/commit/49fd5ac))
## [1.4.5](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.4...rollup-plugin-index-html@1.4.5) (2019-07-22)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.3...rollup-plugin-index-html@1.4.4) (2019-07-19)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.2...rollup-plugin-index-html@1.4.3) (2019-07-15)
### Bug Fixes
* adopt to new testing-karma setup ([bdcc717](https://github.com/open-wc/open-wc/commit/bdcc717))
## [1.4.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.1...rollup-plugin-index-html@1.4.2) (2019-07-13)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.4.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.4.0...rollup-plugin-index-html@1.4.1) (2019-07-13)
**Note:** Version bump only for package rollup-plugin-index-html
# [1.4.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.3.4...rollup-plugin-index-html@1.4.0) (2019-07-08)
### Features
* **rollup-plugin-index-html:** support inline modules ([#525](https://github.com/open-wc/open-wc/issues/525)) ([f79de32](https://github.com/open-wc/open-wc/commit/f79de32))
## [1.3.4](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.3.3...rollup-plugin-index-html@1.3.4) (2019-07-08)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.3.3](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.3.2...rollup-plugin-index-html@1.3.3) (2019-07-08)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.3.2](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.3.1...rollup-plugin-index-html@1.3.2) (2019-07-08)
**Note:** Version bump only for package rollup-plugin-index-html
## [1.3.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.3.0...rollup-plugin-index-html@1.3.1) (2019-07-02)
### Bug Fixes
* **es-dev-server:** don't call next on non-2xx response ([f3e865a](https://github.com/open-wc/open-wc/commit/f3e865a))
# [1.3.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.2.1...rollup-plugin-index-html@1.3.0) (2019-07-02)
### Features
* add es dev server ([2c6a0a8](https://github.com/open-wc/open-wc/commit/2c6a0a8))
## [1.2.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.2.0...rollup-plugin-index-html@1.2.1) (2019-06-30)
### Bug Fixes
* **rollup-plugin-index-html:** no resolve of entry points via import map ([#524](https://github.com/open-wc/open-wc/issues/524)) ([edc4f46](https://github.com/open-wc/open-wc/commit/edc4f46))
# [1.2.0](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.1.1...rollup-plugin-index-html@1.2.0) (2019-06-30)
### Features
* **rollup-plugin-index-html:** support import maps ([#519](https://github.com/open-wc/open-wc/issues/519)) ([8c56540](https://github.com/open-wc/open-wc/commit/8c56540))
## [1.1.1](https://github.com/open-wc/open-wc/compare/rollup-plugin-index-html@1.1.0...rollup-plugin-index-html@1.1.1) (2019-06-23)
**Note:** Version bump only for package rollup-plugin-index-html
# 1.1.0 (2019-06-23)
### Features
* **building-rollup:** add rollup-index-html-plugin ([#510](https://github.com/open-wc/open-wc/issues/510)) ([2ac2d19](https://github.com/open-wc/open-wc/commit/2ac2d19))

View File

@@ -1,271 +0,0 @@
# Rollup Plugin Index HTML
> **WARNING**: This project is deprecated and no longer maintained. See [@open-wc/rollup-plugin-html](https://github.com/open-wc/open-wc/tree/master/packages/rollup-plugin-html) and [@open-wc/rollup-plugin-polyfills-loader](https://github.com/open-wc/open-wc/tree/master/packages/rollup-plugin-polyfills-loader) for replacements.
Rollup plugin to make rollup understand your index.html.
[//]: # 'AUTO INSERT HEADER PREPUBLISH'
1. Takes in a standard index.html:
```html
<html lang="en-GB">
<head>
<title>My app</title>
<style>
my-app {
display: block;
}
</style>
</head>
<body>
<h1>
<span>
Hello world!
</span>
</h1>
<my-app></my-app>
<script>
(function () {
var message = 'hello inline script';
console.log(message);
})();
</script>
<script type="module" src="./app.js"></script>
</body>
</html>
```
2. Extracts any `<script type="module" src="...">` and feeds them to rollup as entry point(s)
3. Outputs the same index.html with updated file hashes and all inline HTML, CSS and JS minified:
```html
<html lang="en-GB">
<head>
<title>My app</title>
<style>
my-app {
display: block;
}
</style>
</head>
<body>
<h1><span>Hello world!</span></h1>
<my-app></my-app>
<script>
console.log('hello inline script');
</script>
<script src="app.202933f045cc9f6cdf51.js"></script>
</body>
</html>
```
4. Optionally adds a loader script for conditionally loading polyfills and/or a separate build for older browsers.
Note that only module scripts with a `src` attribute are used as entrypoints, regular scripts and inline modules are minified but not parsed by rollup.
## Usage
To use this plugin, add it to your rollup configuration and set your index.html as entrypoint:
```js
const path = require('path');
const indexHTML = require('rollup-plugin-index-html');
module.exports = {
input: path.resolve(__dirname, './index.html'),
plugins: [indexHTML(config)],
};
```
## Configuration
### Polyfills
> Note when using `@open-wc/building-rollup` many polyfills are already configured for you.
Depending on which browser you need to support you may need to polyfill certain browser features. To keep your bundles small, we don't serve any polyfills by default. You can enable polyfills in the configuration.
When enabling polyfills a small loader script is injected to your index.html. Polyfills are loaded based on feature detection. This causes a small delay in loading your app. We mediate this by adding a preload link during the build.
To enable polyfills:
```js
indexHTML({
polyfills: {
coreJs: true,
regeneratorRuntime: true,
webcomponents: true,
fetch: true,
intersectionObserver: true,
},
});
```
`core-js` polyfills many language features such as `Promise`, `Symbol` and `String.prototype.includes`. `regeneratorRuntime` is necessary when you compile `async await` code which is transpiled to javascript ES5. These two polyfills are mainly for supporting legacy browsers. They are only loaded on browsers which don't support modules, such as IE11.
The rest of the polyfills target specific browser features, see their documentation for more info:
- [core-js](https://github.com/zloirock/core-js)
- [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime)
- [webcomponents](https://github.com/webcomponents/webcomponentsjs)
- [fetch](https://github.com/github/fetch)
- [intersection-observer](https://github.com/w3c/IntersectionObserver)
If you need a polyfill which is not on this list, consider creating an issue so that we can add it. You can also specify custom polyfills:
```js
indexHTML({
polyfills: {
coreJs: true,
customPolyfills: [
{
// the name of your polyfill
name: 'my-feature',
// expression which is run in the browser to determine if the polyfill should be loaded
test: "'myFeature' in window",
// path to your polyfill
path: require.resolve('my-feature-polyfill/dist/bundled.js'),
// path to the sourcemaps of your polyfill. optional
sourcemapPath: require.resolve('my-feature-polyfill/dist/bundled.js.map'),
},
],
},
});
```
### Multi (legacy and modern) build
> Note when using `@open-wc/building-rollup/modern-and-legacy-config` the multi build is already configured for you
If you need to support non-modern browsers, such IE11 or older versions of chrome, safari and firefox, it's better to create multiple builds of your app.
You can make one build for modern browsers using modern syntax and features, and one build for legacy browsers compiled to javascript ES5 and with more polyfills loaded. This way you don't penalize all your users for your lowest browser target.
To create multiple rollup builds, export an array of rollup configs instead of a single config. Set the `multiBuild` option in both instances of the plugin and set `legacy` option in the legacy build:
```javascript
const path = require('path');
const indexHTML = require('rollup-plugin-index-html');
module.exports = [
{
entry: path.resolve(__dirname, './index.html'),
plugins: [
indexHTML({
multiBuild: true,
polyfills: {
coreJs: true,
regeneratorRuntime: true,
webcomponents: true,
},
}),
],
},
{
entry: path.resolve(__dirname, './index.html'),
module: {
rules: [
// Note: You will probably also want to configure babel for the legacy build.
// this is not a complete example, you will need to add more configuration for babel
{ test: /\.js/, use: { loader: 'babel-loader' } },
],
},
plugins: [
indexHTML({
multiBuild: true,
legacy: true,
}),
],
},
];
```
For the legacy build you do not need to configure any polyfills, as these are already injected by the modern build.
You will probably need to use babel as well to transpile your code to ES5. Remember to change the browser targets for the modern and legacy build accordingly. For example latest 2 of the major browsers for modern and IE11 for the legac build.
### Minification
We use [html-minifier](https://github.com/kangax/html-minifier) for minifcation with a default configuration. You can adjust this configuration by passing a minify object:
```js
indexHTML({
minify: {
// minify options
},
});
```
The options object is passed as is to `html-minifier`. See the documentation of [html-minifier](https://github.com/kangax/html-minifier) for all possible minification options.
It is also possible to turn off minification completely by passing minify:
```js
indexHTML({
minify: false,
});
```
### Non index.html entrypoints
You can use this plugin without an index.html plugin if you still want to make use of the polyfilling features. You can do this by adding a custom template function:
```js
const path = require('path');
const indexHTML = require('rollup-plugin-index-html');
module.exports = {
entry: path.resolve(__dirname, './my-app.js'),
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
},
plugins: [
indexHTML({
template: ({ assets, entries, legacyEntries, variation }) => `
<html>
<head></head>
<body></body>
</html>
`,
}),
],
};
```
### CSP
When loading polyfills we inject a small script in your index.html. If you need CSP you can separate the script in a separate file:
```js
const path = require('path');
const indexHTML = require('rollup-plugin-index-html');
module.exports = {
entry: path.resolve(__dirname, './my-app.js'),
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
},
plugins: [
indexHTML({
polyfills: {
webcomponents: true,
},
loader: 'external',
}),
],
};
```
The template function receives the project's `assets` and `entries`. If applicable it also receives the `legacyEntries` and `variation`.

View File

@@ -1,44 +0,0 @@
{
"name": "rollup-plugin-index-html",
"version": "1.12.8",
"publishConfig": {
"access": "public"
},
"description": "Plugin for generating a index html with rollup",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/open-wc/open-wc.git",
"directory": "packages/webpack-index-html-plugin"
},
"author": "open-wc",
"homepage": "https://github.com/open-wc/open-wc/tree/master/packages/rollup-plugin-index-html",
"main": "rollup-plugin-index-html.js",
"scripts": {
"prepublishOnly": "../../scripts/insert-header.js"
},
"files": [
"*.js",
"src"
],
"keywords": [
"rollup-plugin",
"minify",
"polyfill"
],
"dependencies": {
"@import-maps/resolve": "^1.0.0",
"@open-wc/building-utils": "^2.18.3",
"deepmerge": "^4.2.2",
"lit-html": "^1.0.0",
"md5": "^2.2.1",
"mkdirp": "^0.5.1",
"parse5": "^5.1.1"
},
"devDependencies": {
"@webcomponents/shadycss": "^1.9.4",
"@webcomponents/webcomponentsjs": "^2.4.0",
"intersection-observer": "^0.7.0",
"whatwg-fetch": "^3.0.0"
}
}

View File

@@ -1,179 +0,0 @@
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const deepmerge = require('deepmerge');
const { parseFromString, resolve } = require('@import-maps/resolve');
const { findInlineEntryId } = require('@open-wc/building-utils/index-html');
const { processEntryHtml } = require('./src/process-entry-html.js');
const { createOutput } = require('./src/create-output');
const { createEntriesConfig } = require('./src/create-entries-config');
const { createError } = require('./src/utils');
/** @typedef {import('@open-wc/building-utils/index-html/create-index-html').EntriesConfig} EntriesConfig */
/**
* @typedef {object} TemplateData
* @property {EntriesConfig} entries
* @property {EntriesConfig} [legacyEntries]
*/
/**
* @typedef {object} RollupPluginIndexHTMLConfig
* @property {(data: TemplateData) => string} [template]
* @property {string} [indexFilename]
* @property {boolean} [legacy]
* @property {boolean} [multiBuild]
* @property {boolean} [inject]
* @property {string} [legacyDir]
* @property {string} [indexHTML]
* @property {string} [indexHTMLString]
* @property {string} [rootDir] Path to the root of your application
* @property {import('@open-wc/building-utils/index-html/create-index-html').PolyfillsConfig} [polyfills]
* @property {false|object} [minify] minify configuration, or false to disable minification
* @property {() => Promise<EntriesConfig>} [getLegacyFiles]
* @property {(files: { path: string, content: string }[]) => void} [_outputHandler]
*/
/** @type {Partial<RollupPluginIndexHTMLConfig>} */
const defaultConfig = {
inject: true,
legacyDir: 'legacy',
_outputHandler(files) {
files.forEach(file => {
mkdirp.sync(path.dirname(file.path));
fs.writeFileSync(file.path, file.content, 'utf-8');
});
},
};
/** @type {EntriesConfig} */
let legacyEntries = null;
/**
* @param {RollupPluginIndexHTMLConfig} pluginConfig
*/
module.exports = (pluginConfig = {}) => {
const localPluginConfig = {
...defaultConfig,
...pluginConfig,
};
let outputIndexHTML;
let inlineImportMaps;
let inlineModules;
let importMapCache = null;
let rollupOptions = null;
return {
name: 'index-html',
// Takes the configured index.html input, looks for all defined module scripts and feeds them to rollup.
options(inputConfig) {
// manual index.html, we don't need to parse anything
if (pluginConfig.indexHTML) {
if (typeof inputConfig.input === 'string' && inputConfig.input.endsWith('index.html')) {
throw createError(
'input cannot be an index.html when config.indexHTML was given manually',
);
}
return inputConfig;
}
const result = processEntryHtml(pluginConfig, inputConfig);
({ outputIndexHTML, inlineImportMaps, inlineModules, rollupOptions } = result);
return result.rollupOptions;
},
resolveId(source, importer) {
// if this is an inline entry keep it, load() will take ca,re of it
if (typeof findInlineEntryId(source) === 'number') {
return source;
}
if (Array.isArray(inlineImportMaps) && inlineImportMaps.length > 0) {
// exclude entry points as they may get provided as `main.js` without a path
// which would be considered bare module according to import map spec
if (
rollupOptions.input &&
Array.isArray(rollupOptions.input) &&
rollupOptions.input.includes(source)
) {
return null;
}
const { rootDir = process.cwd() } = localPluginConfig;
const basePath = importer ? importer.replace(rootDir, `${rootDir}::`) : `${rootDir}::`;
if (importMapCache === null) {
inlineImportMaps.forEach(importMapString => {
const newImportMap = parseFromString(importMapString, basePath);
importMapCache = deepmerge(importMapCache, newImportMap);
});
}
const relativeSource = source.replace(rootDir, '');
const resolvedPath = resolve(relativeSource, importMapCache, basePath);
if (resolvedPath) {
return resolvedPath;
}
}
return null;
},
load(id) {
const inlineEntryId = findInlineEntryId(id);
// if this is an inline entry, take the inline module index from the import and return it's content
if (typeof inlineEntryId === 'number') {
return inlineModules[inlineEntryId];
}
// defer loading to other plugins / rollup
return null;
},
// Injects generated module paths into index.html
async generateBundle(outputConfig, bundles) {
const entryFiles = Object.keys(bundles).filter(key => bundles[key].isEntry);
const preloadedFiles = entryFiles.reduce((acc, e) => {
bundles[e].imports.forEach(i => {
if (!acc.includes(i)) {
acc.push(i);
}
});
return acc;
}, []);
if (localPluginConfig.multiBuild) {
if (localPluginConfig.legacy) {
// if this is a multi build, rollup is run twice in parallel. the legacy build
// resolves a promise to signal the modern build which will create the index.html
legacyEntries = createEntriesConfig(
outputConfig,
entryFiles,
undefined,
localPluginConfig.legacyDir,
);
return;
}
if (!legacyEntries) {
throw createError(
`Multi build is configured, but a legacy build did not run. Pass two configs to rollup, where the first is a legacy and the second is a modern build.`,
);
}
}
const entries = createEntriesConfig(outputConfig, entryFiles, preloadedFiles);
const files = createOutput(
localPluginConfig,
outputConfig,
outputIndexHTML,
entries,
legacyEntries,
);
localPluginConfig._outputHandler(files);
legacyEntries = null;
},
};
};

View File

@@ -1,36 +0,0 @@
const path = require('path');
const outputTypes = {
es: 'module',
esm: 'module',
system: 'system',
};
/** @typedef {import('@open-wc/building-utils/index-html/create-index-html').EntriesConfig} EntriesConfig */
/**
* @param {*} outputConfig
* @param {string[]} files
* @param {string[]} [preloadedFiles]
* @param {string} [legacyDir]
* @returns {EntriesConfig}
*/
function createEntriesConfig(outputConfig, files, preloadedFiles, legacyDir) {
if (!(outputConfig.format in outputTypes)) {
throw new Error(
`Unsupported module format: ${outputConfig.format}. Supports formats: esm and system`,
);
}
return {
type: outputTypes[outputConfig.format],
// if this is the legacy build, add the legacy folder to the output
files: legacyDir ? files.map(f => path.posix.join(legacyDir, f)) : files,
// only preload legacy files for now
preloadedFiles: legacyDir ? undefined : preloadedFiles,
};
}
module.exports = {
createEntriesConfig,
};

View File

@@ -1,126 +0,0 @@
const path = require('path');
const fs = require('fs');
const { serialize, parse } = require('parse5');
const { createIndexHTML, minifyIndexHTML } = require('@open-wc/building-utils/index-html');
/** @typedef {import('parse5').Document} ASTNode */
/** @typedef {import('@open-wc/building-utils/index-html/create-index-html').EntriesConfig} EntriesConfig */
/** @typedef {import('../rollup-plugin-index-html').RollupPluginIndexHTMLConfig} RollupPluginIndexHTMLConfig */
/**
* @typedef {object} OutputResult
* @property {string} path
* @property {string} content
*/
/**
* @param {ASTNode} ast
* @returns {ASTNode}
*/
function cloneAST(ast) {
return parse(serialize(ast));
}
/**
* @param {RollupPluginIndexHTMLConfig} pluginConfig
* @param {ASTNode} inputIndexHTML
* @param {EntriesConfig} entries
* @param {EntriesConfig} [legacyEntries]
*/
function getOutputIndexHTML(pluginConfig, inputIndexHTML, entries, legacyEntries) {
/** If there is a user defined template, use that as the base to inject the output into. */
if (pluginConfig.template) {
if (typeof pluginConfig.template !== 'function') {
throw new Error('config.template should be a function.');
}
const templateString = pluginConfig.template({
entries,
legacyEntries,
// variation: variation && variation.toString(),
});
try {
return parse(templateString);
} catch (error) {
throw new Error(`Unable to parse returned from config.template function: ${error.message}`);
}
} else if (pluginConfig.indexHTML) {
if (typeof pluginConfig.indexHTML !== 'string') {
throw new Error('config.indexHTML must be a string');
}
if (!pluginConfig.indexHTML.endsWith('.html')) {
throw new Error('config.indexHTML must be a html file');
}
if (!fs.existsSync(pluginConfig.indexHTML)) {
throw new Error(`No file found at ${pluginConfig.indexHTML}`);
}
const indexHTMLString = fs.readFileSync(pluginConfig.indexHTML, 'utf-8');
try {
return parse(indexHTMLString);
} catch (error) {
throw new Error(`Unable to parse index html at ${pluginConfig.indexHTML}: ${error.message}`);
}
}
/**
* If there is no user defined template the entrypoint was an index.html, and we use that as the base
* for our output. We need to clone it to avoid mutating the inputIndexHTML variable.
*/
return cloneAST(inputIndexHTML);
}
/**
* @param {RollupPluginIndexHTMLConfig} pluginConfig
* @param {ASTNode} inputIndexHTML
* @param {EntriesConfig} entries
* @param {EntriesConfig} [legacyEntries]
* @returns {OutputResult[]}
*/
function injectIntoIndexHTML(pluginConfig, inputIndexHTML, entries, legacyEntries) {
/**
* Inject output files, loader script and polyfills into index.html
*/
if (pluginConfig.inject) {
const result = createIndexHTML(inputIndexHTML, {
...pluginConfig,
entries,
legacyEntries,
});
return [{ path: pluginConfig.indexFilename, content: result.indexHTML }, ...result.files];
}
/**
* If injection is disabled the user takes control, probably with it's own template.
*/
const serialized = serialize(inputIndexHTML);
return [{ path: pluginConfig.indexFilename, content: minifyIndexHTML(serialized) }];
}
/**
* @param {RollupPluginIndexHTMLConfig} pluginConfig
* @param {*} outputConfig
* @param {ASTNode} inputIndexHTML
* @param {EntriesConfig} entries
* @param {EntriesConfig} [legacyEntries]
* @returns {OutputResult[]}
*/
function createOutput(pluginConfig, outputConfig, inputIndexHTML, entries, legacyEntries) {
const mergedPluginConfig = { indexFilename: 'index.html', ...pluginConfig };
const indexHTML = getOutputIndexHTML(mergedPluginConfig, inputIndexHTML, entries, legacyEntries);
const files = injectIntoIndexHTML(mergedPluginConfig, indexHTML, entries, legacyEntries);
const outputDir = path.join(outputConfig.dir);
return files.map(file => ({
...file,
path: path.join(outputDir, file.path),
}));
}
module.exports = {
createOutput,
};

Some files were not shown because too many files have changed in this diff Show More