@internetarchive/collection-browser 4.3.2-alpha-webdev7939.12 → 4.3.2-rc-webdev-8334.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +1 -1
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/app-root.js +0 -4
  11. package/dist/src/app-root.js.map +1 -1
  12. package/dist/src/collection-browser.d.ts +0 -41
  13. package/dist/src/collection-browser.js +36 -128
  14. package/dist/src/collection-browser.js.map +1 -1
  15. package/dist/src/tiles/item-image.d.ts +1 -9
  16. package/dist/src/tiles/item-image.js +2 -22
  17. package/dist/src/tiles/item-image.js.map +1 -1
  18. package/dist/src/tiles/tile-display-value-provider.js +2 -1
  19. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  20. package/dist/test/tiles/grid/item-tile.test.js +2 -2
  21. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  22. package/dist/test/tiles/list/tile-list.test.js +2 -2
  23. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  24. package/eslint.config.mjs +53 -53
  25. package/index.html +24 -24
  26. package/local.archive.org.cert +86 -86
  27. package/local.archive.org.key +27 -27
  28. package/package.json +120 -120
  29. package/renovate.json +6 -6
  30. package/src/app-root.ts +0 -3
  31. package/src/collection-browser.ts +35 -146
  32. package/src/tiles/item-image.ts +1 -28
  33. package/src/tiles/tile-display-value-provider.ts +2 -3
  34. package/test/tiles/grid/item-tile.test.ts +2 -2
  35. package/test/tiles/list/tile-list.test.ts +2 -2
  36. package/tsconfig.json +25 -25
  37. package/web-dev-server.config.mjs +30 -30
  38. package/web-test-runner.config.mjs +52 -52
@@ -421,7 +421,7 @@ export class CollectionBrowser
421
421
  const model = this.dataSource.getTileModelAt(index);
422
422
  /**
423
423
  * If we encounter a model we don't have yet and we're not in the middle of an
424
- * automated scroll, schedule a fetch for the missing page and return undefined.
424
+ * automated scroll, fetch the page and just return undefined.
425
425
  * The datasource will be updated once the page is loaded and the cell will be rendered.
426
426
  *
427
427
  * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
@@ -429,59 +429,9 @@ export class CollectionBrowser
429
429
  */
430
430
  if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
431
431
  const pageNumber = Math.floor(index / this.pageSize) + 1;
432
- this.scheduleDeferredPageFetch(pageNumber);
433
- }
434
- return model;
435
- }
436
-
437
- /**
438
- * Debounce delay for page fetches initiated by new cells becoming visible.
439
- * Tuned so quick scrolling through unloaded regions doesn't send rapid-fire
440
- * search requests for every page we pass through, but to still feel responsive
441
- * when the scroll ends.
442
- */
443
- private static readonly DEFERRED_FETCH_DELAY_MS = 150;
444
-
445
- private deferredFetchTimer = 0;
446
-
447
- /**
448
- * Schedules a fetch for the given page, debounced to ensure we don't
449
- * rapid-fire fetches while scrolling through pages quickly.
450
- *
451
- * If there's no pending fetch timer yet, it will fire a fetch immediately.
452
- * Otherwise, it will reset any existing timer. In either case, a deferred
453
- * fetch for the visible pages is scheduled after a brief delay to account
454
- * for whatever pages we land on after scrolling.
455
- */
456
- private scheduleDeferredPageFetch(pageNumber: number): void {
457
- if (!this.deferredFetchTimer) {
458
432
  this.dataSource.fetchPage(pageNumber);
459
- } else {
460
- window.clearTimeout(this.deferredFetchTimer);
461
- }
462
-
463
- this.deferredFetchTimer = window.setTimeout(() => {
464
- this.deferredFetchTimer = 0;
465
- this.fetchVisiblePages();
466
- }, CollectionBrowser.DEFERRED_FETCH_DELAY_MS);
467
- }
468
-
469
- /**
470
- * Fetch each currently-visible page whose first cell still has no
471
- * loaded model.
472
- */
473
- private fetchVisiblePages(): void {
474
- const visibleIndices = this.infiniteScroller?.getVisibleCellIndices() ?? [];
475
- const visiblePages = new Set(
476
- visibleIndices.map(i => Math.floor(i / this.pageSize) + 1),
477
- );
478
-
479
- for (const page of visiblePages) {
480
- const firstCellOfPage = (page - 1) * this.pageSize;
481
- if (!this.dataSource.getTileModelAt(firstCellOfPage)) {
482
- this.dataSource.fetchPage(page);
483
- }
484
433
  }
434
+ return model;
485
435
  }
486
436
 
487
437
  // this is the total number of tiles we expect if
@@ -916,7 +866,6 @@ export class CollectionBrowser
916
866
  class=${this.infiniteScrollerClasses}
917
867
  itemCount=${this.placeholderType ? 0 : nothing}
918
868
  ariaLandmarkLabel="Search results"
919
- .estimatedCellHeight=${this.estimatedTileHeight}
920
869
  .cellProvider=${this}
921
870
  .placeholderCellTemplate=${this.placeholderCellTemplate}
922
871
  @scrollThresholdReached=${this.scrollThresholdReached}
@@ -938,25 +887,6 @@ export class CollectionBrowser
938
887
  });
939
888
  }
940
889
 
941
- /**
942
- * Best-effort hint of how tall a single rendered tile is, by display mode.
943
- * The scroller uses this to better estimate the size its initial scroll
944
- * spacer and buffer position before real cell heights are measured.
945
- * Should roughly match the placeholder heights since the initial render
946
- * of a new page generally shows placeholders only anyway.
947
- */
948
- private get estimatedTileHeight(): number {
949
- switch (this.displayMode) {
950
- case 'list-detail':
951
- return 80;
952
- case 'list-compact':
953
- return 45;
954
- case 'grid':
955
- default:
956
- return 225;
957
- }
958
- }
959
-
960
890
  /**
961
891
  * Template for the sort & filtering bar that appears atop the search results.
962
892
  */
@@ -1168,7 +1098,7 @@ export class CollectionBrowser
1168
1098
  if ((this.currentPage ?? 1) > 1) {
1169
1099
  this.goToPage(1);
1170
1100
  }
1171
- this.setCurrentPage(1);
1101
+ this.currentPage = 1;
1172
1102
  }
1173
1103
 
1174
1104
  /**
@@ -1941,11 +1871,6 @@ export class CollectionBrowser
1941
1871
  window.removeEventListener('popstate', this.boundNavigationHandler);
1942
1872
  }
1943
1873
 
1944
- if (this.deferredFetchTimer) {
1945
- window.clearTimeout(this.deferredFetchTimer);
1946
- this.deferredFetchTimer = 0;
1947
- }
1948
-
1949
1874
  this.leftColIntersectionObserver?.disconnect();
1950
1875
  this.facetsIntersectionObserver?.disconnect();
1951
1876
  window.removeEventListener('resize', this.updateLeftColumnHeight);
@@ -2198,45 +2123,27 @@ export class CollectionBrowser
2198
2123
  private visibleCellsChanged(
2199
2124
  e: CustomEvent<{ visibleCellIndices: number[] }>,
2200
2125
  ) {
2201
- this.updateVisiblePage(e.detail.visibleCellIndices);
2202
- }
2203
-
2204
- /**
2205
- * Recomputes the current page from the given set of visible cell indices
2206
- * and emits `visiblePageChanged` if the page actually changed.
2207
- */
2208
- private updateVisiblePage(visibleCellIndices: number[]): void {
2209
2126
  if (this.isScrollingToCell) return;
2127
+ const { visibleCellIndices } = e.detail;
2210
2128
  if (visibleCellIndices.length === 0) return;
2211
2129
 
2212
- // The indices aren't necessarily sorted, so sort them here to ensure our
2213
- // calculations below find the right cell/page.
2214
- const sorted = [...visibleCellIndices].sort((a, b) => a - b);
2215
-
2216
2130
  // For page determination, do not count more than a single page of visible cells,
2217
2131
  // since otherwise patrons using very tall screens will be treated as one page
2218
2132
  // further than they actually are.
2219
2133
  const lastIndexWithinCurrentPage =
2220
- Math.min(this.pageSize, sorted.length) - 1;
2221
- const lastVisibleCellIndex = sorted[lastIndexWithinCurrentPage];
2134
+ Math.min(this.pageSize, visibleCellIndices.length) - 1;
2135
+ const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
2222
2136
  const lastVisibleCellPage =
2223
2137
  Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
2224
-
2225
- this.setCurrentPage(lastVisibleCellPage);
2226
- }
2227
-
2228
- /**
2229
- * Sets the current page number and emits a `visiblePageChanged`
2230
- * event if the new page differs from the previous one.
2231
- */
2232
- private setCurrentPage(pageNumber: number): void {
2233
- if (this.currentPage === pageNumber) return;
2234
- this.currentPage = pageNumber;
2235
- this.dispatchEvent(
2236
- new CustomEvent('visiblePageChanged', {
2237
- detail: { pageNumber },
2238
- }),
2239
- );
2138
+ if (this.currentPage !== lastVisibleCellPage) {
2139
+ this.currentPage = lastVisibleCellPage;
2140
+ }
2141
+ const event = new CustomEvent('visiblePageChanged', {
2142
+ detail: {
2143
+ pageNumber: lastVisibleCellPage,
2144
+ },
2145
+ });
2146
+ this.dispatchEvent(event);
2240
2147
  }
2241
2148
 
2242
2149
  // we only want to scroll on the very first query change
@@ -2336,10 +2243,10 @@ export class CollectionBrowser
2336
2243
  this.selectedCreatorFilter = restorationState.selectedCreatorFilter ?? null;
2337
2244
  this.selectedFacets = restorationState.selectedFacets;
2338
2245
  if (!this.suppressURLQuery) this.baseQuery = restorationState.baseQuery;
2339
- this.setCurrentPage(restorationState.currentPage ?? 1);
2246
+ this.currentPage = restorationState.currentPage ?? 1;
2340
2247
  this.minSelectedDate = restorationState.minSelectedDate;
2341
2248
  this.maxSelectedDate = restorationState.maxSelectedDate;
2342
- if (this.currentPage && this.currentPage > 1) {
2249
+ if (this.currentPage > 1) {
2343
2250
  this.goToPage(this.currentPage);
2344
2251
  }
2345
2252
  }
@@ -2416,43 +2323,25 @@ export class CollectionBrowser
2416
2323
  });
2417
2324
  }
2418
2325
 
2419
- private async scrollToPage(pageNumber: number): Promise<void> {
2420
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
2421
-
2422
- // Wait for the infinite scroller be rendered before proceeding
2423
- let waitAttempts = 0;
2424
- while (!this.infiniteScroller && waitAttempts < 20) {
2425
- await this.updateComplete;
2426
- waitAttempts++;
2427
- }
2428
- if (!this.infiniteScroller) return;
2429
-
2430
- // The scroller have its default `itemCount=0`, so propagate our estimated
2431
- // tile count before jumping to the desired page.
2432
- if (this.infiniteScroller.itemCount < this.estimatedTileCount) {
2433
- this.infiniteScroller.itemCount = this.estimatedTileCount;
2434
- await this.updateComplete;
2435
- }
2436
-
2437
- // Without this setTimeout(0), Safari just pauses until the `fetchPage`
2438
- // is complete then scrolls to the cell.
2439
- await new Promise<void>(resolve => {
2440
- setTimeout(resolve, 0);
2326
+ private scrollToPage(pageNumber: number): Promise<void> {
2327
+ return new Promise(resolve => {
2328
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
2329
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
2330
+ // then scrolls to the cell
2331
+ setTimeout(() => {
2332
+ this.isScrollingToCell = true;
2333
+ this.infiniteScroller?.scrollToCell(cellIndexToScrollTo, true);
2334
+ // This timeout is to give the scroll animation time to finish
2335
+ // then updating the infinite scroller once we're done scrolling
2336
+ // There's no scroll animation completion callback so we're
2337
+ // giving it 0.5s to finish.
2338
+ setTimeout(() => {
2339
+ this.isScrollingToCell = false;
2340
+ this.infiniteScroller?.refreshAllVisibleCells();
2341
+ resolve();
2342
+ }, 500);
2343
+ }, 0);
2441
2344
  });
2442
-
2443
- this.isScrollingToCell = true;
2444
- const scrolled = await this.infiniteScroller.scrollToCell(
2445
- cellIndexToScrollTo,
2446
- true,
2447
- );
2448
- this.isScrollingToCell = false;
2449
- this.infiniteScroller.refreshAllVisibleCells();
2450
-
2451
- // After we finish scrolling, recompute the visible page from the new state
2452
- // so that it doesn't fall out of sync.
2453
- if (scrolled) {
2454
- this.updateVisiblePage(this.infiniteScroller.getVisibleCellIndices());
2455
- }
2456
2345
  }
2457
2346
 
2458
2347
  /**
@@ -1,11 +1,4 @@
1
- import {
2
- css,
3
- CSSResultGroup,
4
- html,
5
- LitElement,
6
- nothing,
7
- PropertyValues,
8
- } from 'lit';
1
+ import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
9
2
  import { customElement, property, query, state } from 'lit/decorators.js';
10
3
  import { ClassInfo, classMap } from 'lit/directives/class-map.js';
11
4
 
@@ -19,14 +12,6 @@ import { searchIcon } from '../assets/img/icons/mediatype/search';
19
12
 
20
13
  @customElement('item-image')
21
14
  export class ItemImage extends LitElement {
22
- /**
23
- * Map to cache which identifiers have waveform-style thumbnails, so that
24
- * they can have their waveform styling applied immediately, rather than
25
- * waiting for the image content to load before applying it (which can
26
- * cause noticeable flicker when such tiles refresh).
27
- */
28
- private static readonly waveformByIdentifier = new Map<string, boolean>();
29
-
30
15
  @property({ type: Object }) model?: TileModel;
31
16
 
32
17
  @property({ type: String }) baseImageUrl?: string;
@@ -45,15 +30,6 @@ export class ItemImage extends LitElement {
45
30
 
46
31
  @query('img') private baseImage!: HTMLImageElement;
47
32
 
48
- protected willUpdate(changed: PropertyValues): void {
49
- if (changed.has('model')) {
50
- // If this identifier is known to have a waveform image, then set isWaveform upfront
51
- const identifier = this.model?.identifier;
52
- this.isWaveform =
53
- ItemImage.waveformByIdentifier.get(identifier as string) === true;
54
- }
55
- }
56
-
57
33
  render() {
58
34
  return html`
59
35
  <div class=${classMap(this.itemBaseClass)}>${this.imageTemplate}</div>
@@ -173,9 +149,6 @@ export class ItemImage extends LitElement {
173
149
  this.baseImage.naturalWidth / this.baseImage.naturalHeight === 4
174
150
  ) {
175
151
  this.isWaveform = true;
176
- if (this.model?.identifier) {
177
- ItemImage.waveformByIdentifier.set(this.model.identifier, true);
178
- }
179
152
  }
180
153
  }
181
154
 
@@ -124,9 +124,8 @@ export class TileDisplayValueProvider {
124
124
  .toISOString()
125
125
  .replace(/[TZ:-]/g, '')
126
126
  .replace(/\..*/, '');
127
- const captureHref = `https://web.archive.org/web/${captureDateStr}/${encodeURIComponent(
128
- url,
129
- )}`;
127
+ // url must not be percent-encoded — Wayback Machine matches on the raw URL
128
+ const captureHref = `https://web.archive.org/web/${captureDateStr}/${url}`;
130
129
  const captureText = formatDate(date, 'long');
131
130
 
132
131
  return html` <a href=${captureHref}> ${captureText} </a> `;
@@ -453,7 +453,7 @@ describe('Item Tile', () => {
453
453
  const firstDateLink = captureDatesUl?.children[0]?.querySelector('a[href]');
454
454
  expect(firstDateLink, 'first date link').to.exist;
455
455
  expect(firstDateLink?.getAttribute('href')).to.equal(
456
- 'https://web.archive.org/web/20100102123456/https%3A%2F%2Fexample.com%2F',
456
+ 'https://web.archive.org/web/20100102123456/https://example.com/',
457
457
  );
458
458
  expect(firstDateLink?.textContent?.trim()).to.equal('Jan 02, 2010');
459
459
 
@@ -461,7 +461,7 @@ describe('Item Tile', () => {
461
461
  captureDatesUl?.children[1]?.querySelector('a[href]');
462
462
  expect(secondDateLink, 'second date link').to.exist;
463
463
  expect(secondDateLink?.getAttribute('href')).to.equal(
464
- 'https://web.archive.org/web/20110203124321/https%3A%2F%2Fexample.com%2F',
464
+ 'https://web.archive.org/web/20110203124321/https://example.com/',
465
465
  );
466
466
  expect(secondDateLink?.textContent?.trim()).to.equal('Feb 03, 2011');
467
467
  });
@@ -509,7 +509,7 @@ describe('List Tile', () => {
509
509
  const firstDateLink = captureDatesUl?.children[0]?.querySelector('a[href]');
510
510
  expect(firstDateLink, 'first date link').to.exist;
511
511
  expect(firstDateLink?.getAttribute('href')).to.equal(
512
- 'https://web.archive.org/web/20100102123456/https%3A%2F%2Fexample.com%2F',
512
+ 'https://web.archive.org/web/20100102123456/https://example.com/',
513
513
  );
514
514
  expect(firstDateLink?.textContent?.trim()).to.equal('Jan 02, 2010');
515
515
 
@@ -517,7 +517,7 @@ describe('List Tile', () => {
517
517
  captureDatesUl?.children[1]?.querySelector('a[href]');
518
518
  expect(secondDateLink, 'second date link').to.exist;
519
519
  expect(secondDateLink?.getAttribute('href')).to.equal(
520
- 'https://web.archive.org/web/20110203124321/https%3A%2F%2Fexample.com%2F',
520
+ 'https://web.archive.org/web/20110203124321/https://example.com/',
521
521
  );
522
522
  expect(secondDateLink?.textContent?.trim()).to.equal('Feb 03, 2011');
523
523
  });
package/tsconfig.json CHANGED
@@ -1,25 +1,25 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "moduleResolution": "bundler",
6
- "noEmitOnError": true,
7
- "lib": [
8
- "ESNext",
9
- "dom",
10
- "dom.iterable"
11
- ],
12
- "strict": true,
13
- "esModuleInterop": false,
14
- "allowSyntheticDefaultImports": true,
15
- "experimentalDecorators": true,
16
- "importHelpers": true,
17
- "outDir": "dist",
18
- "sourceMap": true,
19
- "inlineSources": true,
20
- "rootDir": "./",
21
- "declaration": true,
22
- "useDefineForClassFields": false,
23
- },
24
- "include": ["src", "test", "index.ts", "types"],
25
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "bundler",
6
+ "noEmitOnError": true,
7
+ "lib": [
8
+ "ESNext",
9
+ "dom",
10
+ "dom.iterable"
11
+ ],
12
+ "strict": true,
13
+ "esModuleInterop": false,
14
+ "allowSyntheticDefaultImports": true,
15
+ "experimentalDecorators": true,
16
+ "importHelpers": true,
17
+ "outDir": "dist",
18
+ "sourceMap": true,
19
+ "inlineSources": true,
20
+ "rootDir": "./",
21
+ "declaration": true,
22
+ "useDefineForClassFields": false,
23
+ },
24
+ "include": ["src", "test", "index.ts", "types"],
25
+ }
@@ -1,30 +1,30 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- nodeResolve: true,
8
- open: '/',
9
- watch: !hmr,
10
-
11
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
- // esbuildTarget: 'auto'
13
-
14
- /** Set appIndex to enable SPA routing */
15
- // appIndex: 'demo/index.html',
16
-
17
- /** Confgure bare import resolve plugin */
18
- // nodeResolve: {
19
- // exportConditions: ['browser', 'development']
20
- // },
21
-
22
- plugins: [
23
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
- ],
26
-
27
- http2: true,
28
- sslCert: './local.archive.org.cert',
29
- sslKey: './local.archive.org.key',
30
- });
1
+ // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
+
3
+ /** Use Hot Module replacement by adding --hmr to the start command */
4
+ const hmr = process.argv.includes('--hmr');
5
+
6
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ nodeResolve: true,
8
+ open: '/',
9
+ watch: !hmr,
10
+
11
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
12
+ // esbuildTarget: 'auto'
13
+
14
+ /** Set appIndex to enable SPA routing */
15
+ // appIndex: 'demo/index.html',
16
+
17
+ /** Confgure bare import resolve plugin */
18
+ // nodeResolve: {
19
+ // exportConditions: ['browser', 'development']
20
+ // },
21
+
22
+ plugins: [
23
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
24
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
25
+ ],
26
+
27
+ http2: true,
28
+ sslCert: './local.archive.org.cert',
29
+ sslKey: './local.archive.org.key',
30
+ });
@@ -1,52 +1,52 @@
1
- import rollupImage from '@rollup/plugin-image';
2
- import { rollupAdapter } from '@web/dev-server-rollup';
3
- // import { playwrightLauncher } from '@web/test-runner-playwright';
4
-
5
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
6
-
7
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
8
- /** Test files to run */
9
- files: 'dist/test/**/*.test.js',
10
-
11
- /** Resolve bare module imports */
12
- nodeResolve: {
13
- exportConditions: ['browser', 'development'],
14
- },
15
-
16
- mimeTypes: {
17
- '**/*.scss': 'js',
18
- '**/*.css': 'js',
19
- '**/*.svg': 'js',
20
- '**/*.json': 'js',
21
- },
22
-
23
- /** Filter out lit dev mode logs */
24
- filterBrowserLogs(log) {
25
- for (const arg of log.args) {
26
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
27
- return false;
28
- }
29
- }
30
- return true;
31
- },
32
-
33
- plugins: [rollupAdapter(rollupImage())],
34
-
35
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
36
- // esbuildTarget: 'auto',
37
-
38
- /** Amount of browsers to run concurrently */
39
- // concurrentBrowsers: 2,
40
-
41
- /** Amount of test files per browser to test concurrently */
42
- // concurrency: 1,
43
-
44
- /** Browsers to run tests on */
45
- // browsers: [
46
- // playwrightLauncher({ product: 'chromium' }),
47
- // playwrightLauncher({ product: 'firefox' }),
48
- // playwrightLauncher({ product: 'webkit' }),
49
- // ],
50
-
51
- // See documentation for all available options
52
- });
1
+ import rollupImage from '@rollup/plugin-image';
2
+ import { rollupAdapter } from '@web/dev-server-rollup';
3
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
4
+
5
+ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
6
+
7
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
8
+ /** Test files to run */
9
+ files: 'dist/test/**/*.test.js',
10
+
11
+ /** Resolve bare module imports */
12
+ nodeResolve: {
13
+ exportConditions: ['browser', 'development'],
14
+ },
15
+
16
+ mimeTypes: {
17
+ '**/*.scss': 'js',
18
+ '**/*.css': 'js',
19
+ '**/*.svg': 'js',
20
+ '**/*.json': 'js',
21
+ },
22
+
23
+ /** Filter out lit dev mode logs */
24
+ filterBrowserLogs(log) {
25
+ for (const arg of log.args) {
26
+ if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
27
+ return false;
28
+ }
29
+ }
30
+ return true;
31
+ },
32
+
33
+ plugins: [rollupAdapter(rollupImage())],
34
+
35
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
36
+ // esbuildTarget: 'auto',
37
+
38
+ /** Amount of browsers to run concurrently */
39
+ // concurrentBrowsers: 2,
40
+
41
+ /** Amount of test files per browser to test concurrently */
42
+ // concurrency: 1,
43
+
44
+ /** Browsers to run tests on */
45
+ // browsers: [
46
+ // playwrightLauncher({ product: 'chromium' }),
47
+ // playwrightLauncher({ product: 'firefox' }),
48
+ // playwrightLauncher({ product: 'webkit' }),
49
+ // ],
50
+
51
+ // See documentation for all available options
52
+ });