@internetarchive/collection-browser 4.3.2-rc-webdev-8334.3 → 4.4.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.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +1 -1
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.js +676 -672
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +41 -0
- package/dist/src/collection-browser.js +890 -797
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/tiles/item-image.d.ts +9 -1
- package/dist/src/tiles/item-image.js +50 -30
- package/dist/src/tiles/item-image.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +120 -120
- package/renovate.json +6 -6
- package/src/app-root.ts +1254 -1251
- package/src/collection-browser.ts +3161 -3049
- package/src/data-source/collection-browser-data-source.ts +1465 -1465
- package/src/tiles/item-image.ts +214 -187
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -52
package/src/tiles/item-image.ts
CHANGED
|
@@ -1,187 +1,214 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
CSSResultGroup,
|
|
4
|
+
html,
|
|
5
|
+
LitElement,
|
|
6
|
+
nothing,
|
|
7
|
+
PropertyValues,
|
|
8
|
+
} from 'lit';
|
|
9
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
10
|
+
import { ClassInfo, classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
|
|
12
|
+
import type { TileModel } from '../models';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
baseItemImageStyles,
|
|
16
|
+
waveformGradientStyles,
|
|
17
|
+
} from '../styles/item-image-styles';
|
|
18
|
+
import { searchIcon } from '../assets/img/icons/mediatype/search';
|
|
19
|
+
|
|
20
|
+
@customElement('item-image')
|
|
21
|
+
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
|
+
@property({ type: Object }) model?: TileModel;
|
|
31
|
+
|
|
32
|
+
@property({ type: String }) baseImageUrl?: string;
|
|
33
|
+
|
|
34
|
+
@property({ type: Boolean }) isListTile = false;
|
|
35
|
+
|
|
36
|
+
@property({ type: Boolean }) isCompactTile = false;
|
|
37
|
+
|
|
38
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
39
|
+
|
|
40
|
+
@property({ type: Boolean }) suppressBlurring = false;
|
|
41
|
+
|
|
42
|
+
@state() private isWaveform = false;
|
|
43
|
+
|
|
44
|
+
@state() private isNotFound = false;
|
|
45
|
+
|
|
46
|
+
@query('img') private baseImage!: HTMLImageElement;
|
|
47
|
+
|
|
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
|
+
render() {
|
|
58
|
+
return html`
|
|
59
|
+
<div class=${classMap(this.itemBaseClass)}>${this.imageTemplate}</div>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private get imageTemplate() {
|
|
64
|
+
if (this.model?.mediatype === 'search') {
|
|
65
|
+
return html`${searchIcon}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return html`
|
|
69
|
+
<img
|
|
70
|
+
class=${classMap(this.itemImageClass)}
|
|
71
|
+
src="${this.imageSrc}"
|
|
72
|
+
alt=""
|
|
73
|
+
@load=${this.onLoad}
|
|
74
|
+
@error=${this.onError}
|
|
75
|
+
/>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Helpers
|
|
81
|
+
*/
|
|
82
|
+
private get imageSrc() {
|
|
83
|
+
if (this.isNotFound) return this.notFoundSrc;
|
|
84
|
+
|
|
85
|
+
// Use the correct image for web capture tiles, if possible
|
|
86
|
+
if (this.model?.captureDates && this.model.identifier) {
|
|
87
|
+
try {
|
|
88
|
+
const url = new URL(this.model.identifier);
|
|
89
|
+
const domain = encodeURIComponent(url.hostname);
|
|
90
|
+
return this.baseImageUrl
|
|
91
|
+
? `https://web.archive.org/thumb/${domain}?generate=1`
|
|
92
|
+
: nothing;
|
|
93
|
+
} catch {
|
|
94
|
+
return `${this.baseImageUrl}/images/notfound.png`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Use the thumbnail URL specified in the model if it exists
|
|
99
|
+
if (this.model?.thumbnailUrl) return this.model.thumbnailUrl;
|
|
100
|
+
|
|
101
|
+
// Don't try to load invalid image URLs
|
|
102
|
+
return this.baseImageUrl && this.model?.identifier
|
|
103
|
+
? `${this.baseImageUrl}/services/img/${this.model.identifier}`
|
|
104
|
+
: nothing;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private get notFoundSrc() {
|
|
108
|
+
return this.baseImageUrl
|
|
109
|
+
? `${this.baseImageUrl}/images/notfound.png`
|
|
110
|
+
: nothing;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private get hashBasedGradient() {
|
|
114
|
+
if (!this.model?.identifier) {
|
|
115
|
+
return 'waveform-grad0';
|
|
116
|
+
}
|
|
117
|
+
const gradient = this.hashStrToInt(this.model.identifier) % 6; // returns 0-5
|
|
118
|
+
return `waveform-grad${gradient}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private hashStrToInt(str: string): number {
|
|
122
|
+
return str
|
|
123
|
+
.split('')
|
|
124
|
+
.reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Classes
|
|
129
|
+
*/
|
|
130
|
+
private get itemBaseClass(): ClassInfo {
|
|
131
|
+
return {
|
|
132
|
+
'drop-shadow': true,
|
|
133
|
+
'list-box': this.isListTile,
|
|
134
|
+
'search-image': this.model?.mediatype === 'search',
|
|
135
|
+
[this.hashBasedGradient]: this.isWaveform,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private get itemImageClass(): ClassInfo {
|
|
140
|
+
const hasSensitiveContent = !!(
|
|
141
|
+
this.model?.contentWarning || this.model?.loginRequired
|
|
142
|
+
);
|
|
143
|
+
const shouldBlur = hasSensitiveContent && !this.suppressBlurring;
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
contain: !this.isCompactTile && !this.isWaveform,
|
|
147
|
+
cover: this.isCompactTile,
|
|
148
|
+
blur: shouldBlur,
|
|
149
|
+
waveform: this.isWaveform,
|
|
150
|
+
'account-image': this.isAccountImage, // for account tile image
|
|
151
|
+
'collection-image': this.model?.mediatype === 'collection', // for collection tile image
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Helper function to determine if account tile image
|
|
157
|
+
*/
|
|
158
|
+
private get isAccountImage() {
|
|
159
|
+
return (
|
|
160
|
+
this.model?.mediatype === 'account' &&
|
|
161
|
+
!this.isCompactTile &&
|
|
162
|
+
!this.isListTile
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Event listener sets isWaveform true if image is waveform
|
|
168
|
+
*/
|
|
169
|
+
private onLoad() {
|
|
170
|
+
if (
|
|
171
|
+
(this.model?.mediatype === 'audio' ||
|
|
172
|
+
this.model?.mediatype === 'etree') &&
|
|
173
|
+
this.baseImage.naturalWidth / this.baseImage.naturalHeight === 4
|
|
174
|
+
) {
|
|
175
|
+
this.isWaveform = true;
|
|
176
|
+
if (this.model?.identifier) {
|
|
177
|
+
ItemImage.waveformByIdentifier.set(this.model.identifier, true);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private onError() {
|
|
183
|
+
this.isNotFound = true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* CSS
|
|
188
|
+
*/
|
|
189
|
+
static get styles(): CSSResultGroup {
|
|
190
|
+
return [
|
|
191
|
+
baseItemImageStyles,
|
|
192
|
+
waveformGradientStyles,
|
|
193
|
+
css`
|
|
194
|
+
img {
|
|
195
|
+
height: var(--imgHeight, 16rem);
|
|
196
|
+
width: var(--imgWidth, 16rem);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.search-image {
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
background: rgb(245, 245, 247);
|
|
204
|
+
border-radius: 4px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
svg {
|
|
208
|
+
height: 10rem;
|
|
209
|
+
width: 10rem;
|
|
210
|
+
}
|
|
211
|
+
`,
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
}
|
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
|
+
});
|