kopia lustrzana https://github.com/shoelace-style/shoelace
				
				
				
			update dependencies, cleanup, refine (#642)
* update dependencies, cleanup, refine fixes #637 * update CI command to verifypull/644/head
							rodzic
							
								
									46f05224ab
								
							
						
					
					
						commit
						ca346ccbb2
					
				|  | @ -5,13 +5,12 @@ name: Node.js CI | ||||||
| 
 | 
 | ||||||
| on: | on: | ||||||
|   push: |   push: | ||||||
|     branches: [ next ] |     branches: [next] | ||||||
|   pull_request: |   pull_request: | ||||||
|     branches: [ next ] |     branches: [next] | ||||||
| 
 | 
 | ||||||
| jobs: | jobs: | ||||||
|   build: |   build: | ||||||
| 
 |  | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
| 
 | 
 | ||||||
|     strategy: |     strategy: | ||||||
|  | @ -20,13 +19,12 @@ jobs: | ||||||
|         # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |         # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||||||
| 
 | 
 | ||||||
|     steps: |     steps: | ||||||
|     - uses: actions/checkout@v2 |       - uses: actions/checkout@v2 | ||||||
|     - name: Use Node.js ${{ matrix.node-version }} |       - name: Use Node.js ${{ matrix.node-version }} | ||||||
|       uses: actions/setup-node@v2 |         uses: actions/setup-node@v2 | ||||||
|       with: |         with: | ||||||
|         node-version: ${{ matrix.node-version }} |           node-version: ${{ matrix.node-version }} | ||||||
|         cache: 'npm' |           cache: 'npm' | ||||||
|     - run: npx playwright install-deps |       - run: npx playwright install-deps | ||||||
|     - run: npm ci |       - run: npm ci | ||||||
|     - run: npm run build --if-present |       - run: npm run verify | ||||||
|     - run: npm test |  | ||||||
|  |  | ||||||
|  | @ -0,0 +1,4 @@ | ||||||
|  | #!/bin/sh | ||||||
|  | . "$(dirname "$0")/_/husky.sh" | ||||||
|  | 
 | ||||||
|  | npx --no-install lint-staged | ||||||
|  | @ -4,7 +4,9 @@ | ||||||
| .github | .github | ||||||
| dist | dist | ||||||
| docs/*.md | docs/*.md | ||||||
|  | docs/search.json | ||||||
| src/components/icon/icons | src/components/icon/icons | ||||||
|  | src/react/index.ts | ||||||
| node_modules | node_modules | ||||||
| package-lock.json | package-lock.json | ||||||
| tsconfig.json | tsconfig.json | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import fs from 'fs'; | import fs from 'fs'; | ||||||
| import { parse } from 'comment-parser'; | import { parse } from 'comment-parser'; | ||||||
| import pascalCase from 'pascal-case'; | import { pascalCase } from 'pascal-case'; | ||||||
| 
 | 
 | ||||||
| const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | ||||||
| const { name, description, version, author, homepage, license } = packageData; | const { name, description, version, author, homepage, license } = packageData; | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis | ||||||
| - Refactored `<sl-breadcrumb-item>`, `<sl-button>`, `<sl-card>`, `<sl-dialog>`, `<sl-drawer>`, `<sl-input>`, `<sl-range>`, `<sl-select>`, and `<sl-textarea>` to use a Reactive Controller for slot detection | - Refactored `<sl-breadcrumb-item>`, `<sl-button>`, `<sl-card>`, `<sl-dialog>`, `<sl-drawer>`, `<sl-input>`, `<sl-range>`, `<sl-select>`, and `<sl-textarea>` to use a Reactive Controller for slot detection | ||||||
| - Refactored internal id usage in `<sl-details>`, `<sl-dialog>`, `<sl-drawer>`, and `<sl-dropdown>` | - Refactored internal id usage in `<sl-details>`, `<sl-dialog>`, `<sl-drawer>`, and `<sl-dropdown>` | ||||||
| - Removed `position: relative` from the common component stylesheet | - Removed `position: relative` from the common component stylesheet | ||||||
|  | - Updated all dependencies to latest versions | ||||||
| 
 | 
 | ||||||
| ## 2.0.0-beta.63 | ## 2.0.0-beta.63 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,4 @@ | ||||||
|  | export default { | ||||||
|  |   '*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}': 'cspell --no-must-find-files', | ||||||
|  |   '*': 'prettier --write --ignore-unknown' | ||||||
|  | }; | ||||||
										
											
												Plik diff jest za duży
												Load Diff
											
										
									
								
							
							
								
								
									
										68
									
								
								package.json
								
								
								
								
							
							
						
						
									
										68
									
								
								package.json
								
								
								
								
							|  | @ -32,16 +32,21 @@ | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "start": "node scripts/build.js --bundle --serve", |     "start": "node scripts/build.js --bundle --serve", | ||||||
|     "build": "node scripts/build.js --bundle --types --copydir \"docs/dist\"", |     "build": "node scripts/build.js --bundle --types --copydir \"docs/dist\"", | ||||||
|     "prepublishOnly": "npm run build && npm run test", |     "verify": "npm run spellcheck && npm run prettier:check && npm run ts-check && npm run build && npm run test", | ||||||
|  |     "prepublishOnly": "npm run verify", | ||||||
|     "prettier": "prettier --write --loglevel warn .", |     "prettier": "prettier --write --loglevel warn .", | ||||||
|     "create": "plop --plopfile scripts/plop/plopfile.cjs", |     "prettier:check": "prettier --check --loglevel warn .", | ||||||
|  |     "ts-check": "tsc --noEmit", | ||||||
|  |     "create": "plop --plopfile scripts/plop/plopfile.js", | ||||||
|     "test": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit", |     "test": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit", | ||||||
|     "test:watch": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit --watch", |     "test:watch": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit --watch", | ||||||
|     "spellcheck": "cspell \"**/*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}\"" |     "spellcheck": "cspell \"**/*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}\" --no-progress", | ||||||
|  |     "list-outdated-dependencies": "npm-check-updates --format repo --peer", | ||||||
|  |     "update-dependencies": "npm-check-updates --peer -u && npm install && npm run prettier && npm run verify" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@lit-labs/react": "^1.0.1", |     "@lit-labs/react": "^1.0.1", | ||||||
|     "@popperjs/core": "^2.7.0", |     "@popperjs/core": "^2.11.2", | ||||||
|     "@shoelace-style/animations": "^1.1.0", |     "@shoelace-style/animations": "^1.1.0", | ||||||
|     "@shoelace-style/localize": "^2.1.3", |     "@shoelace-style/localize": "^2.1.3", | ||||||
|     "color": "4.1", |     "color": "4.1", | ||||||
|  | @ -49,48 +54,37 @@ | ||||||
|     "qr-creator": "^1.0.0" |     "qr-creator": "^1.0.0" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@custom-elements-manifest/analyzer": "^0.4.12", |     "@custom-elements-manifest/analyzer": "^0.5.7", | ||||||
|     "@open-wc/testing": "^2.5.33", |     "@open-wc/testing": "^3.0.3", | ||||||
|     "@types/color": "^3.0.1", |     "@types/color": "^3.0.2", | ||||||
|     "@types/react": "^17.0.33", |     "@types/react": "^17.0.38", | ||||||
|     "@web/dev-server-esbuild": "^0.2.12", |     "@web/dev-server-esbuild": "^0.2.16", | ||||||
|     "@web/test-runner": "^0.13.5", |     "@web/test-runner": "^0.13.23", | ||||||
|     "@web/test-runner-playwright": "^0.8.8", |     "@web/test-runner-playwright": "^0.8.8", | ||||||
|     "bluebird": "^3.7.2", |  | ||||||
|     "bootstrap-icons": "^1.7.2", |     "bootstrap-icons": "^1.7.2", | ||||||
|     "browser-sync": "^2.26.14", |     "browser-sync": "^2.27.7", | ||||||
|     "chalk": "^4.1.0", |     "chalk": "^5.0.0", | ||||||
|     "command-line-args": "^5.2.0", |     "command-line-args": "^5.2.0", | ||||||
|     "comment-parser": "^1.1.5", |     "comment-parser": "^1.3.0", | ||||||
|     "concurrently": "^5.3.0", |  | ||||||
|     "cspell": "^5.14.0", |     "cspell": "^5.14.0", | ||||||
|     "del": "^6.0.0", |     "del": "^6.0.0", | ||||||
|     "download": "^8.0.0", |     "download": "^8.0.0", | ||||||
|     "esbuild": "^0.12.4", |     "esbuild": "^0.14.10", | ||||||
|     "front-matter": "^4.0.2", |     "front-matter": "^4.0.2", | ||||||
|     "get-port": "^5.1.1", |     "get-port": "^6.0.0", | ||||||
|     "globby": "^11.0.4", |     "globby": "^12.0.2", | ||||||
|     "husky": "^4.3.8", |     "husky": "^7.0.4", | ||||||
|     "lint-staged": "^12.1.4", |     "lint-staged": "^12.1.5", | ||||||
|     "lunr": "^2.3.9", |     "lunr": "^2.3.9", | ||||||
|     "mkdirp": "^0.5.5", |     "npm-check-updates": "^12.1.0", | ||||||
|     "plop": "^2.7.4", |     "pascal-case": "^3.1.2", | ||||||
|  |     "plop": "^3.0.5", | ||||||
|     "prettier": "^2.5.1", |     "prettier": "^2.5.1", | ||||||
|     "react": "^17.0.2", |     "react": "^17.0.2", | ||||||
|     "recursive-copy": "^2.0.11", |     "recursive-copy": "^2.0.13", | ||||||
|     "sinon": "^11.1.1", |     "sinon": "^12.0.1", | ||||||
|     "strip-css-comments": "^4.1.0", |     "strip-css-comments": "^5.0.0", | ||||||
|     "tslib": "^2.2.0", |     "tslib": "^2.3.1", | ||||||
|     "typescript": "^4.2.4", |     "typescript": "^4.5.4" | ||||||
|     "wait-on": "^5.2.1" |  | ||||||
|   }, |  | ||||||
|   "husky": { |  | ||||||
|     "hooks": { |  | ||||||
|       "pre-commit": "lint-staged" |  | ||||||
|     } |  | ||||||
|   }, |  | ||||||
|   "lint-staged": { |  | ||||||
|     "*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}": "cspell --no-must-find-files", |  | ||||||
|     "*": "prettier --write --ignore-unknown" |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
|  | import fs from 'fs'; | ||||||
| import browserSync from 'browser-sync'; | import browserSync from 'browser-sync'; | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import commandLineArgs from 'command-line-args'; | import commandLineArgs from 'command-line-args'; | ||||||
| import copy from 'recursive-copy'; | import copy from 'recursive-copy'; | ||||||
| import del from 'del'; | import del from 'del'; | ||||||
| import esbuild from 'esbuild'; | import esbuild from 'esbuild'; | ||||||
| import getPort from 'get-port'; | import getPort, { portNumbers } from 'get-port'; | ||||||
| import glob from 'globby'; | import { globby } from 'globby'; | ||||||
| import mkdirp from 'mkdirp'; |  | ||||||
| import { execSync } from 'child_process'; | import { execSync } from 'child_process'; | ||||||
| 
 | 
 | ||||||
| const bs = browserSync.create(); | const bs = browserSync.create(); | ||||||
|  | @ -22,7 +22,7 @@ const { bundle, copydir, dir, serve, types } = commandLineArgs([ | ||||||
| const outdir = dir; | const outdir = dir; | ||||||
| 
 | 
 | ||||||
| del.sync(outdir); | del.sync(outdir); | ||||||
| mkdirp.sync(outdir); | fs.mkdirSync(outdir, { recursive: true }); | ||||||
| 
 | 
 | ||||||
| (async () => { | (async () => { | ||||||
|   try { |   try { | ||||||
|  | @ -47,15 +47,15 @@ mkdirp.sync(outdir); | ||||||
|         // The whole shebang
 |         // The whole shebang
 | ||||||
|         './src/shoelace.ts', |         './src/shoelace.ts', | ||||||
|         // Components
 |         // Components
 | ||||||
|         ...(await glob('./src/components/**/!(*.(style|test)).ts')), |         ...(await globby('./src/components/**/!(*.(style|test)).ts')), | ||||||
|         // Translations
 |         // Translations
 | ||||||
|         ...(await glob('./src/translations/**/*.ts')), |         ...(await globby('./src/translations/**/*.ts')), | ||||||
|         // Public utilities
 |         // Public utilities
 | ||||||
|         ...(await glob('./src/utilities/**/!(*.(style|test)).ts')), |         ...(await globby('./src/utilities/**/!(*.(style|test)).ts')), | ||||||
|         // Theme stylesheets
 |         // Theme stylesheets
 | ||||||
|         ...(await glob('./src/themes/**/!(*.test).ts')), |         ...(await globby('./src/themes/**/!(*.test).ts')), | ||||||
|         // React wrappers
 |         // React wrappers
 | ||||||
|         ...(await glob('./src/react/**/*.ts')) |         ...(await globby('./src/react/**/*.ts')) | ||||||
|       ], |       ], | ||||||
|       outdir, |       outdir, | ||||||
|       chunkNames: 'chunks/[name].[hash]', |       chunkNames: 'chunks/[name].[hash]', | ||||||
|  | @ -93,7 +93,7 @@ mkdirp.sync(outdir); | ||||||
|   // Dev server
 |   // Dev server
 | ||||||
|   if (serve) { |   if (serve) { | ||||||
|     const port = await getPort({ |     const port = await getPort({ | ||||||
|       port: getPort.makeRange(4000, 4999) |       port: portNumbers(4000, 4999) | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // Make sure docs/dist is empty since we're serving it virtually
 |     // Make sure docs/dist is empty since we're serving it virtually
 | ||||||
|  |  | ||||||
|  | @ -4,19 +4,19 @@ | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import commandLineArgs from 'command-line-args'; | import commandLineArgs from 'command-line-args'; | ||||||
| import fs from 'fs/promises'; | import fs from 'fs/promises'; | ||||||
| import glob from 'globby'; | import { mkdirSync } from 'fs'; | ||||||
| import mkdirp from 'mkdirp'; | import { globbySync } from 'globby'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import prettier from 'prettier'; | import prettier from 'prettier'; | ||||||
| import stripComments from 'strip-css-comments'; | import stripComments from 'strip-css-comments'; | ||||||
| 
 | 
 | ||||||
| const { outdir } = commandLineArgs({ name: 'outdir', type: String }); | const { outdir } = commandLineArgs({ name: 'outdir', type: String }); | ||||||
| const files = glob.sync('./src/themes/**/*.styles.ts'); | const files = globbySync('./src/themes/**/*.styles.ts'); | ||||||
| const themesDir = path.join(outdir, 'themes'); | const themesDir = path.join(outdir, 'themes'); | ||||||
| 
 | 
 | ||||||
| console.log('Generating stylesheets'); | console.log('Generating stylesheets'); | ||||||
| 
 | 
 | ||||||
| mkdirp.sync(themesDir); | mkdirSync(themesDir, { recursive: true }); | ||||||
| 
 | 
 | ||||||
| try { | try { | ||||||
|   files.map(async file => { |   files.map(async file => { | ||||||
|  |  | ||||||
|  | @ -1,17 +1,15 @@ | ||||||
| //
 | //
 | ||||||
| // This script downloads and generates icons and icon metadata.
 | // This script downloads and generates icons and icon metadata.
 | ||||||
| //
 | //
 | ||||||
| import Promise from 'bluebird'; |  | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import commandLineArgs from 'command-line-args'; | import commandLineArgs from 'command-line-args'; | ||||||
| import copy from 'recursive-copy'; | import copy from 'recursive-copy'; | ||||||
| import del from 'del'; | import del from 'del'; | ||||||
| import download from 'download'; | import download from 'download'; | ||||||
| import mkdirp from 'mkdirp'; |  | ||||||
| import fm from 'front-matter'; | import fm from 'front-matter'; | ||||||
| import { readFileSync } from 'fs'; | import { readFileSync, mkdirSync } from 'fs'; | ||||||
| import { stat, readFile, writeFile } from 'fs/promises'; | import { stat, readFile, writeFile } from 'fs/promises'; | ||||||
| import glob from 'globby'; | import { globby } from 'globby'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| 
 | 
 | ||||||
| const { outdir } = commandLineArgs({ name: 'outdir', type: String }); | const { outdir } = commandLineArgs({ name: 'outdir', type: String }); | ||||||
|  | @ -38,7 +36,7 @@ let numIcons = 0; | ||||||
|     // Copy icons
 |     // Copy icons
 | ||||||
|     console.log(`Copying icons and license`); |     console.log(`Copying icons and license`); | ||||||
|     await del([iconDir]); |     await del([iconDir]); | ||||||
|     await mkdirp(iconDir); |     mkdirSync(iconDir, { recursive: true }); | ||||||
|     await Promise.all([ |     await Promise.all([ | ||||||
|       copy(`${srcPath}/icons`, iconDir), |       copy(`${srcPath}/icons`, iconDir), | ||||||
|       copy(`${srcPath}/LICENSE.md`, path.join(iconDir, 'LICENSE.md')), |       copy(`${srcPath}/LICENSE.md`, path.join(iconDir, 'LICENSE.md')), | ||||||
|  | @ -47,20 +45,22 @@ let numIcons = 0; | ||||||
| 
 | 
 | ||||||
|     // Generate metadata
 |     // Generate metadata
 | ||||||
|     console.log(`Generating icon metadata`); |     console.log(`Generating icon metadata`); | ||||||
|     const files = await glob(`${srcPath}/docs/content/icons/**/*.md`); |     const files = await globby(`${srcPath}/docs/content/icons/**/*.md`); | ||||||
| 
 | 
 | ||||||
|     const metadata = await Promise.map(files, async file => { |     const metadata = await Promise.all( | ||||||
|       const name = path.basename(file, path.extname(file)); |       files.map(async file => { | ||||||
|       const data = fm(await readFile(file, 'utf8')).attributes; |         const name = path.basename(file, path.extname(file)); | ||||||
|       numIcons++; |         const data = fm(await readFile(file, 'utf8')).attributes; | ||||||
|  |         numIcons++; | ||||||
| 
 | 
 | ||||||
|       return { |         return { | ||||||
|         name, |           name, | ||||||
|         title: data.title, |           title: data.title, | ||||||
|         categories: data.categories, |           categories: data.categories, | ||||||
|         tags: data.tags |           tags: data.tags | ||||||
|       }; |         }; | ||||||
|     }); |       }) | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     await writeFile(path.join(iconDir, 'icons.json'), JSON.stringify(metadata, null, 2), 'utf8'); |     await writeFile(path.join(iconDir, 'icons.json'), JSON.stringify(metadata, null, 2), 'utf8'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,9 +1,8 @@ | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import fs from 'fs'; | import fs from 'fs'; | ||||||
| import del from 'del'; | import del from 'del'; | ||||||
| import mkdirp from 'mkdirp'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import pascalCase from 'pascal-case'; | import { pascalCase } from 'pascal-case'; | ||||||
| import prettier from 'prettier'; | import prettier from 'prettier'; | ||||||
| import prettierConfig from '../prettier.config.cjs'; | import prettierConfig from '../prettier.config.cjs'; | ||||||
| import { getAllComponents } from './shared.js'; | import { getAllComponents } from './shared.js'; | ||||||
|  | @ -12,7 +11,7 @@ const outdir = path.join('./src/react'); | ||||||
| 
 | 
 | ||||||
| // Clear build directory
 | // Clear build directory
 | ||||||
| del.sync(outdir); | del.sync(outdir); | ||||||
| mkdirp.sync(outdir); | fs.mkdirSync(outdir, { recursive: true }); | ||||||
| 
 | 
 | ||||||
| // Fetch component metadata
 | // Fetch component metadata
 | ||||||
| const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8')); | const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8')); | ||||||
|  | @ -29,7 +28,7 @@ components.map(component => { | ||||||
|   const componentFile = path.join(componentDir, 'index.ts'); |   const componentFile = path.join(componentDir, 'index.ts'); | ||||||
|   const importPath = component.modulePath.replace(/^src\//, '').replace(/\.ts$/, ''); |   const importPath = component.modulePath.replace(/^src\//, '').replace(/\.ts$/, ''); | ||||||
| 
 | 
 | ||||||
|   mkdirp.sync(componentDir); |   fs.mkdirSync(componentDir, { recursive: true }); | ||||||
| 
 | 
 | ||||||
|   const events = (component.events || []).map(event => `${`on${pascalCase(event.name)}`}: '${event.name}'`).join(',\n'); |   const events = (component.events || []).map(event => `${`on${pascalCase(event.name)}`}: '${event.name}'`).join(',\n'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import commandLineArgs from 'command-line-args'; | import commandLineArgs from 'command-line-args'; | ||||||
| import fs from 'fs'; | import fs from 'fs'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import glob from 'globby'; | import { globby } from 'globby'; | ||||||
| import lunr from 'lunr'; | import lunr from 'lunr'; | ||||||
| import { getAllComponents } from './shared.js'; | import { getAllComponents } from './shared.js'; | ||||||
| 
 | 
 | ||||||
|  | @ -59,7 +59,7 @@ console.log('Generating search index for documentation'); | ||||||
|     return members.join(' '); |     return members.join(' '); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const files = await glob('./docs/**/*.md'); |   const files = await globby('./docs/**/*.md'); | ||||||
|   const map = {}; |   const map = {}; | ||||||
|   const searchIndex = lunr(function () { |   const searchIndex = lunr(function () { | ||||||
|     // The search index uses these field names extensively, so shortening them can save some serious bytes. The initial
 |     // The search index uses these field names extensively, so shortening them can save some serious bytes. The initial
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| module.exports = function (plop) { | export default function (plop) { | ||||||
|   plop.setHelper('tagWithoutPrefix', tag => tag.replace(/^sl-/, '')); |   plop.setHelper('tagWithoutPrefix', tag => tag.replace(/^sl-/, '')); | ||||||
| 
 | 
 | ||||||
|   plop.setHelper('tagToTitle', tag => { |   plop.setHelper('tagToTitle', tag => { | ||||||
|  | @ -64,4 +64,4 @@ module.exports = function (plop) { | ||||||
|       } |       } | ||||||
|     ] |     ] | ||||||
|   }); |   }); | ||||||
| }; | } | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| import { expect, fixture, html } from '@open-wc/testing'; | import { expect, fixture, html } from '@open-wc/testing'; | ||||||
| import { aTimeout } from '@open-wc/testing-helpers'; |  | ||||||
| 
 | 
 | ||||||
| import '../../../dist/shoelace.js'; | import '../../../dist/shoelace.js'; | ||||||
| import type SlAvatar from './avatar'; | import type SlAvatar from './avatar'; | ||||||
|  | @ -24,9 +23,8 @@ describe('<sl-avatar>', () => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   describe('when provided an image and label parameter', async () => { |   describe('when provided an image and label parameter', async () => { | ||||||
|     const image = |     const image = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; | ||||||
|       'https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80'; |     const label = 'Small transparent square'; | ||||||
|     const label = 'Gray tabby kitten looking down'; |  | ||||||
|     before(async () => { |     before(async () => { | ||||||
|       el = await fixture<SlAvatar>(html`<sl-avatar image="${image}" label="${label}"></sl-avatar>`); |       el = await fixture<SlAvatar>(html`<sl-avatar image="${image}" label="${label}"></sl-avatar>`); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -4,11 +4,37 @@ import sinon from 'sinon'; | ||||||
| import '../../../dist/shoelace.js'; | import '../../../dist/shoelace.js'; | ||||||
| import type SlInclude from './include'; | import type SlInclude from './include'; | ||||||
| 
 | 
 | ||||||
|  | const stubbedFetchResponse: Response = { | ||||||
|  |   headers: new Headers(), | ||||||
|  |   ok: true, | ||||||
|  |   redirected: false, | ||||||
|  |   status: 200, | ||||||
|  |   statusText: 'OK', | ||||||
|  |   type: 'default', | ||||||
|  |   url: '', | ||||||
|  |   json: () => Promise.resolve({}), | ||||||
|  |   text: () => Promise.resolve(''), | ||||||
|  |   blob: sinon.fake(), | ||||||
|  |   arrayBuffer: sinon.fake(), | ||||||
|  |   formData: sinon.fake(), | ||||||
|  |   bodyUsed: false, | ||||||
|  |   body: null, | ||||||
|  |   clone: sinon.fake() | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| describe('<sl-include>', () => { | describe('<sl-include>', () => { | ||||||
|  |   afterEach(() => { | ||||||
|  |     sinon.verifyAndRestore(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|   it('should load content and emit sl-load', async () => { |   it('should load content and emit sl-load', async () => { | ||||||
|     const el = await fixture<SlInclude>( |     sinon.stub(window, 'fetch').resolves({ | ||||||
|       html` <sl-include src="https://jsonplaceholder.typicode.com/posts/1"></sl-include> ` |       ...stubbedFetchResponse, | ||||||
|     ); |       ok: true, | ||||||
|  |       status: 200, | ||||||
|  |       text: () => Promise.resolve('"id": 1') | ||||||
|  |     }); | ||||||
|  |     const el = await fixture<SlInclude>(html` <sl-include src="/found"></sl-include> `); | ||||||
|     const loadHandler = sinon.spy(); |     const loadHandler = sinon.spy(); | ||||||
| 
 | 
 | ||||||
|     el.addEventListener('sl-load', loadHandler); |     el.addEventListener('sl-load', loadHandler); | ||||||
|  | @ -19,9 +45,13 @@ describe('<sl-include>', () => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('should emit sl-error when content cannot be loaded', async () => { |   it('should emit sl-error when content cannot be loaded', async () => { | ||||||
|     const el = await fixture<SlInclude>( |     sinon.stub(window, 'fetch').resolves({ | ||||||
|       html` <sl-include src="https://jsonplaceholder.typicode.com/not-found"></sl-include> ` |       ...stubbedFetchResponse, | ||||||
|     ); |       ok: false, | ||||||
|  |       status: 404, | ||||||
|  |       text: () => Promise.resolve('{}') | ||||||
|  |     }); | ||||||
|  |     const el = await fixture<SlInclude>(html` <sl-include src="/not-found"></sl-include> `); | ||||||
|     const loadHandler = sinon.spy(); |     const loadHandler = sinon.spy(); | ||||||
| 
 | 
 | ||||||
|     el.addEventListener('sl-error', loadHandler); |     el.addEventListener('sl-error', loadHandler); | ||||||
|  |  | ||||||
|  | @ -1,45 +0,0 @@ | ||||||
| //
 |  | ||||||
| // A lightweight debounce implementation
 |  | ||||||
| //
 |  | ||||||
| export function debounce(callback: (...args: [any]) => void, delay: number) { |  | ||||||
|   let timer: any; |  | ||||||
| 
 |  | ||||||
|   return function () { |  | ||||||
|     if (timer) { |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     callback.apply(this, arguments); |  | ||||||
|     timer = setTimeout(() => (timer = null), delay); |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| //
 |  | ||||||
| // A lightweight throttle implementation
 |  | ||||||
| //
 |  | ||||||
| export function throttle(callback: (...args: [any]) => void, delay: number) { |  | ||||||
|   let isThrottled = false; |  | ||||||
|   let args: any; |  | ||||||
|   let context: any; |  | ||||||
| 
 |  | ||||||
|   function wrapper() { |  | ||||||
|     if (isThrottled) { |  | ||||||
|       args = arguments; |  | ||||||
|       context = this; |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     isThrottled = true; |  | ||||||
|     callback.apply(this, arguments); |  | ||||||
| 
 |  | ||||||
|     setTimeout(() => { |  | ||||||
|       isThrottled = false; |  | ||||||
|       if (args) { |  | ||||||
|         wrapper.apply(context, args); |  | ||||||
|         args = context = null; |  | ||||||
|       } |  | ||||||
|     }, delay); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   return wrapper; |  | ||||||
| } |  | ||||||
|  | @ -1,80 +1,35 @@ | ||||||
| { | { | ||||||
|   "compilerOptions": { |   "compilerOptions": { | ||||||
|     /* Visit https://aka.ms/tsconfig.json to read more about this file */ |     /* Visit https://aka.ms/tsconfig.json to read more about this file */ | ||||||
| 
 |     "target": "es2017", | ||||||
|     /* Basic Options */ |     "module": "es2015", | ||||||
|     // "incremental": true                    /* Enable incremental compilation */, |     "lib": [ | ||||||
|     "target": "es2017"                        /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, |  | ||||||
|     "module": "es2015"                        /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, |  | ||||||
|     "lib": [                                  /* Specify library files to be included in the compilation. */ |  | ||||||
|       "dom", |       "dom", | ||||||
|       "dom.Iterable", |       "dom.Iterable", | ||||||
|       "es2020" |       "es2020" | ||||||
|     ], |     ], | ||||||
|     // "allowJs": true,                       /* Allow javascript files to be compiled. */ |     "declaration": true, | ||||||
|     // "checkJs": true,                       /* Report errors in .js files. */ |     "outDir": "./dist", | ||||||
|     // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ |     "rootDir": "./src", | ||||||
|     "declaration": true                       /* Generates corresponding '.d.ts' file. */, |     "strict": true, | ||||||
|     // "declarationMap": true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */ |     "strictPropertyInitialization": false, | ||||||
|     // "sourceMap": true                      /* Generates corresponding '.map' file. */, |     "strictFunctionTypes": false, | ||||||
|     // "outFile": "./",                       /* Concatenate and emit output to single file. */ |     "noImplicitThis": false, | ||||||
|     "outDir": "./dist"                        /* Redirect output structure to the directory. */, |     "noUnusedLocals": true, | ||||||
|     "rootDir": "./src"                        /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, |     "noUnusedParameters": true, | ||||||
|     // "composite": true,                     /* Enable project compilation */ |     "noImplicitReturns": true, | ||||||
|     // "tsBuildInfoFile": "./",               /* Specify file to store incremental compilation information */ |     "noFallthroughCasesInSwitch": true, | ||||||
|     // "removeComments": true,                /* Do not emit comments to output. */ |     "moduleResolution": "node", | ||||||
|     // "noEmit": true,                        /* Do not emit outputs. */ |     "esModuleInterop": true, | ||||||
|     // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */ |     "experimentalDecorators": true, | ||||||
|     // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ |  | ||||||
|     // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ |  | ||||||
| 
 |  | ||||||
|     /* Strict Type-Checking Options */ |  | ||||||
|     // "strict": true,                        /* Enable all strict type-checking options. */ |  | ||||||
|     "noImplicitAny": true                     /* Raise error on expressions and declarations with an implied 'any' type. */, |  | ||||||
|     "strictNullChecks": true                  /* Enable strict null checks. */, |  | ||||||
|     // "strictFunctionTypes": true,           /* Enable strict checking of function types. */ |  | ||||||
|     // "strictBindCallApply": true,           /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ |  | ||||||
|     // "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */ |  | ||||||
|     // "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */ |  | ||||||
|     // "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */ |  | ||||||
| 
 |  | ||||||
|     /* Additional Checks */ |  | ||||||
|     "noUnusedLocals": true                    /* Report errors on unused locals. */, |  | ||||||
|     "noUnusedParameters": true                /* Report errors on unused parameters. */, |  | ||||||
|     "noImplicitReturns": true                 /* Report error when not all code paths in function return a value. */, |  | ||||||
|     "noFallthroughCasesInSwitch": true        /* Report errors for fallthrough cases in switch statement. */, |  | ||||||
|     // "noUncheckedIndexedAccess": true,      /* Include 'undefined' in index signature results */ |  | ||||||
| 
 |  | ||||||
|     /* Module Resolution Options */ |  | ||||||
|     "moduleResolution": "node"                /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, |  | ||||||
|     // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */ |  | ||||||
|     // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ |  | ||||||
|     // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */ |  | ||||||
|     // "typeRoots": [],                       /* List of folders to include type definitions from. */ |  | ||||||
|     // "types": [],                           /* Type declaration files to be included in compilation. */ |  | ||||||
|     // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ |  | ||||||
|     "esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, |  | ||||||
|     // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */ |  | ||||||
|     // "allowUmdGlobalAccess": true,          /* Allow accessing UMD globals from modules. */ |  | ||||||
| 
 |  | ||||||
|     /* Source Map Options */ |  | ||||||
|     // "sourceRoot": "",                      /* Specify the location where debugger should locate TypeScript files instead of source locations. */ |  | ||||||
|     // "mapRoot": "",                         /* Specify the location where debugger should locate map files instead of generated locations. */ |  | ||||||
|     // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */ |  | ||||||
|     // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ |  | ||||||
| 
 |  | ||||||
|     /* Experimental Options */ |  | ||||||
|     "experimentalDecorators": true,           /* Enables experimental support for ES7 decorators. */ |  | ||||||
|     // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */ |  | ||||||
| 
 |  | ||||||
|     /* Advanced Options */ |  | ||||||
|     "removeComments": true, |     "removeComments": true, | ||||||
|     "skipLibCheck": true                      /* Skip type checking of declaration files. */, |     "skipLibCheck": true, | ||||||
|     "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */ |     "forceConsistentCasingInFileNames": true, | ||||||
|  |     "useUnknownInCatchVariables": true | ||||||
|   }, |   }, | ||||||
|   "exclude": [ |   "exclude": [ | ||||||
|     "docs", |     "docs", | ||||||
|     "dist", |     "dist", | ||||||
|     "src/**/*.test.ts" |     "src/**/*.test.ts" | ||||||
|   ] |   ] | ||||||
| } | } | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Jason O'Neill
						Jason O'Neill