@internetarchive/recaptcha-manager 2.0.0 → 2.0.1

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 (58) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.editorconfig +29 -0
  3. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/ci.yml +27 -0
  4. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/gh-pages-main.yml +39 -0
  5. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.github/workflows/pr-preview.yml +63 -0
  6. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.husky/pre-commit +1 -0
  7. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/.prettierignore +1 -0
  8. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/LICENSE +661 -0
  9. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/README.md +63 -0
  10. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/coverage/.gitignore +3 -0
  11. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/coverage/.placeholder +0 -0
  12. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/demo/app-root.ts +111 -0
  13. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/demo/index.html +21 -0
  14. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/eslint.config.mjs +53 -0
  15. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/index.ts +10 -0
  16. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/package-lock.json +11336 -0
  17. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/package.json +76 -0
  18. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/renovate.json +6 -0
  19. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/src/recaptcha-manager.ts +114 -0
  20. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/src/recaptcha-widget.ts +148 -0
  21. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/ssl/server.crt +22 -0
  22. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/ssl/server.key +28 -0
  23. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/mock-grecaptcha.ts +85 -0
  24. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/mock-lazy-loader.ts +36 -0
  25. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/test/recaptcha-manager.test.ts +201 -0
  26. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/tsconfig.json +31 -0
  27. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/vite.config.ts +25 -0
  28. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/web-dev-server.config.mjs +32 -0
  29. package/.claude/worktrees/recaptcha-google-url-hardcode-79a528/web-test-runner.config.mjs +41 -0
  30. package/.editorconfig +29 -29
  31. package/.github/workflows/ci.yml +27 -27
  32. package/.github/workflows/gh-pages-main.yml +39 -39
  33. package/.github/workflows/pr-preview.yml +63 -63
  34. package/.husky/pre-commit +1 -1
  35. package/.prettierignore +1 -1
  36. package/LICENSE +661 -661
  37. package/README.md +63 -63
  38. package/coverage/.gitignore +2 -2
  39. package/demo/app-root.ts +111 -111
  40. package/demo/index.html +21 -21
  41. package/dist/demo/app-root.js +31 -31
  42. package/dist/demo/app-root.js.map +1 -1
  43. package/dist/src/recaptcha-manager.d.ts +2 -1
  44. package/dist/src/recaptcha-manager.js +3 -2
  45. package/dist/src/recaptcha-manager.js.map +1 -1
  46. package/dist/test/mock-lazy-loader.js.map +1 -1
  47. package/dist/test/recaptcha-manager.test.js +1 -1
  48. package/dist/test/recaptcha-manager.test.js.map +1 -1
  49. package/eslint.config.mjs +53 -53
  50. package/package.json +76 -76
  51. package/renovate.json +6 -6
  52. package/src/recaptcha-manager.ts +114 -113
  53. package/ssl/server.key +28 -28
  54. package/test/mock-lazy-loader.ts +36 -36
  55. package/test/recaptcha-manager.test.ts +201 -199
  56. package/tsconfig.json +31 -31
  57. package/web-dev-server.config.mjs +32 -32
  58. package/web-test-runner.config.mjs +41 -41
@@ -1,36 +1,36 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {
3
- BundleType,
4
- LazyLoaderServiceEvents,
5
- LazyLoaderServiceInterface,
6
- } from '@internetarchive/lazy-loader-service';
7
- import { Unsubscribe } from 'nanoevents';
8
-
9
- export class MockLazyLoaderService implements LazyLoaderServiceInterface {
10
- loadScriptSrc?: string;
11
-
12
- constructor(private onloadFn: () => unknown = () => {}) {}
13
-
14
- on<E extends keyof LazyLoaderServiceEvents>(
15
- event: E,
16
- callback: LazyLoaderServiceEvents[E],
17
- ): Unsubscribe {
18
- throw new Error('Method not implemented.');
19
- }
20
-
21
- async loadBundle(bundle: {
22
- module?: string;
23
- nomodule?: string;
24
- }): Promise<void> {
25
- console.debug('loadBundle', bundle);
26
- }
27
-
28
- async loadScript(options: {
29
- src: string;
30
- bundleType?: BundleType;
31
- attributes?: Record<string, string>;
32
- }): Promise<void> {
33
- this.loadScriptSrc = options.src;
34
- this.onloadFn();
35
- }
36
- }
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ BundleType,
4
+ LazyLoaderServiceEvents,
5
+ LazyLoaderServiceInterface,
6
+ } from '@internetarchive/lazy-loader-service';
7
+ import { Unsubscribe } from 'nanoevents';
8
+
9
+ export class MockLazyLoaderService implements LazyLoaderServiceInterface {
10
+ loadScriptSrc?: string;
11
+
12
+ constructor(private onloadFn: () => unknown = () => {}) {}
13
+
14
+ on<E extends keyof LazyLoaderServiceEvents>(
15
+ event: E,
16
+ callback: LazyLoaderServiceEvents[E],
17
+ ): Unsubscribe {
18
+ throw new Error('Method not implemented.');
19
+ }
20
+
21
+ async loadBundle(bundle: {
22
+ module?: string;
23
+ nomodule?: string;
24
+ }): Promise<void> {
25
+ console.debug('loadBundle', bundle);
26
+ }
27
+
28
+ async loadScript(options: {
29
+ src: string;
30
+ bundleType?: BundleType;
31
+ attributes?: Record<string, string>;
32
+ }): Promise<void> {
33
+ this.loadScriptSrc = options.src;
34
+ this.onloadFn();
35
+ }
36
+ }
@@ -1,199 +1,201 @@
1
- import { expect } from '@open-wc/testing';
2
- import { MockGrecaptcha } from './mock-grecaptcha';
3
- import { RecaptchaManager } from '../src/recaptcha-manager';
4
- import { MockLazyLoaderService } from './mock-lazy-loader';
5
-
6
- const mockLazyLoader = new MockLazyLoaderService();
7
-
8
- describe('ReCaptcha Management', () => {
9
- describe('ReCaptcha Manager', () => {
10
- it('can return recaptchas', async () => {
11
- const mockGrecaptcha = new MockGrecaptcha({
12
- mode: 'success',
13
- });
14
- mockGrecaptcha.response = 'foo';
15
- const recaptchaManager = new RecaptchaManager({
16
- lazyLoader: mockLazyLoader,
17
- grecaptchaLibrary: mockGrecaptcha,
18
- defaultSiteKey: '123',
19
- });
20
- const recaptcha = await recaptchaManager.getRecaptchaWidget();
21
- const result = await recaptcha.execute();
22
- expect(result).to.equal('foo');
23
- });
24
-
25
- it('throws an error if no site key found', async () => {
26
- const mockGrecaptcha = new MockGrecaptcha({
27
- mode: 'success',
28
- });
29
- mockGrecaptcha.response = 'foo';
30
- const recaptchaManager = new RecaptchaManager({
31
- lazyLoader: mockLazyLoader,
32
- grecaptchaLibrary: mockGrecaptcha,
33
- });
34
- try {
35
- await recaptchaManager.getRecaptchaWidget();
36
- expect.fail('should not get here');
37
- } catch (e) {
38
- expect((e as Error).message).to.equal(
39
- 'The reCaptcha widget requires a site key',
40
- );
41
- }
42
- });
43
-
44
- it('returns a cached version if one already exists for a given site key', async () => {
45
- const mockGrecaptcha = new MockGrecaptcha({
46
- mode: 'success',
47
- });
48
- mockGrecaptcha.response = 'foo';
49
- const recaptchaManager = new RecaptchaManager({
50
- lazyLoader: mockLazyLoader,
51
- grecaptchaLibrary: mockGrecaptcha,
52
- defaultSiteKey: '123',
53
- });
54
- const recaptcha1 = await recaptchaManager.getRecaptchaWidget();
55
- const recaptcha2 = await recaptchaManager.getRecaptchaWidget();
56
- expect(recaptcha1).to.equal(recaptcha2);
57
- });
58
-
59
- it('loads the recaptcha library if needed', async () => {
60
- // Mock lazy loader that mimics the grecaptcha script calling the callback on load
61
- const mockLazyLoaderWithCallback = new MockLazyLoaderService(() => {
62
- window.grecaptcha = new MockGrecaptcha({
63
- mode: 'success',
64
- });
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- (window as any).grecaptchaLoadedCallback();
67
- });
68
-
69
- const recaptchaManager = new RecaptchaManager({
70
- lazyLoader: mockLazyLoaderWithCallback,
71
- defaultSiteKey: '123',
72
- timeout: 100,
73
- });
74
-
75
- await recaptchaManager.getRecaptchaWidget();
76
- const loadUrl = mockLazyLoaderWithCallback.loadScriptSrc;
77
- expect(
78
- loadUrl?.includes('recaptcha/api.js?onload=grecaptchaLoadedCallback'),
79
- ).to.be.true;
80
- });
81
-
82
- it('rejects after specified timeout if grecaptcha fails to execute callback', async () => {
83
- const recaptchaManager = new RecaptchaManager({
84
- lazyLoader: mockLazyLoader,
85
- defaultSiteKey: '123',
86
- timeout: 100,
87
- });
88
-
89
- try {
90
- await recaptchaManager.getRecaptchaWidget();
91
- expect.fail('recaptcha load did not time out as expected');
92
- } catch (err) {
93
- expect(err).to.be.instanceOf(Error);
94
- expect((err as Error).message).to.equal(
95
- 'grecaptcha failed to execute callback',
96
- );
97
- }
98
- });
99
-
100
- it('can set the timeout delay', async () => {
101
- const recaptchaManager = new RecaptchaManager({
102
- lazyLoader: mockLazyLoader,
103
- defaultSiteKey: '123',
104
- });
105
-
106
- recaptchaManager.setTimeoutDelay(1);
107
-
108
- try {
109
- await recaptchaManager.getRecaptchaWidget();
110
- expect.fail('recaptcha load did not time out as expected');
111
- } catch (err) {
112
- expect(err).to.be.instanceOf(Error);
113
- expect((err as Error).message).to.equal(
114
- 'grecaptcha failed to execute callback',
115
- );
116
- }
117
- });
118
- });
119
-
120
- describe('ReCaptcha Widget', () => {
121
- it('can error properly like a Promise', async () => {
122
- const mockGrecaptcha = new MockGrecaptcha({
123
- mode: 'error',
124
- });
125
- const recaptchaManager = new RecaptchaManager({
126
- lazyLoader: mockLazyLoader,
127
- grecaptchaLibrary: mockGrecaptcha,
128
- defaultSiteKey: '123',
129
- });
130
- const recaptcha = await recaptchaManager.getRecaptchaWidget();
131
-
132
- try {
133
- await recaptcha.execute();
134
- expect.fail('should not get here');
135
- } catch (error) {
136
- expect((error as Error).message).to.equal('error');
137
- }
138
- });
139
-
140
- it('can expire properly like a Promise', async () => {
141
- const mockGrecaptcha = new MockGrecaptcha({
142
- mode: 'expired',
143
- });
144
- const recaptchaManager = new RecaptchaManager({
145
- lazyLoader: mockLazyLoader,
146
- grecaptchaLibrary: mockGrecaptcha,
147
- defaultSiteKey: '123',
148
- });
149
- const recaptcha = await recaptchaManager.getRecaptchaWidget();
150
-
151
- try {
152
- await recaptcha.execute();
153
- expect.fail('should not get here');
154
- } catch (error) {
155
- expect((error as Error).message).to.equal('expired');
156
- }
157
- });
158
-
159
- it('resets the captcha after execution', async () => {
160
- const mockGrecaptcha = new MockGrecaptcha({
161
- mode: 'success',
162
- addDelay: true,
163
- });
164
- const recaptchaManager = new RecaptchaManager({
165
- lazyLoader: mockLazyLoader,
166
- grecaptchaLibrary: mockGrecaptcha,
167
- defaultSiteKey: '123',
168
- });
169
- const recaptcha = await recaptchaManager.getRecaptchaWidget();
170
-
171
- expect(mockGrecaptcha.resetCallCount).to.equal(0);
172
- await recaptcha.execute();
173
- expect(mockGrecaptcha.resetCallCount).to.equal(1);
174
- await recaptcha.execute();
175
- expect(mockGrecaptcha.resetCallCount).to.equal(2);
176
- });
177
-
178
- // there's no way to know if the user has dismissed the captcha so if another execution
179
- // comes through while the captcha is still active, it will be reset
180
- it('resets the captcha if another execution gets called', async () => {
181
- const mockGrecaptcha = new MockGrecaptcha({
182
- mode: 'success',
183
- addDelay: true,
184
- });
185
- const recaptchaManager = new RecaptchaManager({
186
- lazyLoader: mockLazyLoader,
187
- grecaptchaLibrary: mockGrecaptcha,
188
- defaultSiteKey: '123',
189
- });
190
- const recaptcha = await recaptchaManager.getRecaptchaWidget();
191
-
192
- expect(mockGrecaptcha.resetCallCount).to.equal(0);
193
- recaptcha.execute();
194
- expect(mockGrecaptcha.resetCallCount).to.equal(0);
195
- await recaptcha.execute();
196
- expect(mockGrecaptcha.resetCallCount).to.equal(2);
197
- });
198
- });
199
- });
1
+ import { expect } from '@open-wc/testing';
2
+ import { MockGrecaptcha } from './mock-grecaptcha';
3
+ import { RecaptchaManager } from '../src/recaptcha-manager';
4
+ import { MockLazyLoaderService } from './mock-lazy-loader';
5
+
6
+ const mockLazyLoader = new MockLazyLoaderService();
7
+
8
+ describe('ReCaptcha Management', () => {
9
+ describe('ReCaptcha Manager', () => {
10
+ it('can return recaptchas', async () => {
11
+ const mockGrecaptcha = new MockGrecaptcha({
12
+ mode: 'success',
13
+ });
14
+ mockGrecaptcha.response = 'foo';
15
+ const recaptchaManager = new RecaptchaManager({
16
+ lazyLoader: mockLazyLoader,
17
+ grecaptchaLibrary: mockGrecaptcha,
18
+ defaultSiteKey: '123',
19
+ });
20
+ const recaptcha = await recaptchaManager.getRecaptchaWidget();
21
+ const result = await recaptcha.execute();
22
+ expect(result).to.equal('foo');
23
+ });
24
+
25
+ it('throws an error if no site key found', async () => {
26
+ const mockGrecaptcha = new MockGrecaptcha({
27
+ mode: 'success',
28
+ });
29
+ mockGrecaptcha.response = 'foo';
30
+ const recaptchaManager = new RecaptchaManager({
31
+ lazyLoader: mockLazyLoader,
32
+ grecaptchaLibrary: mockGrecaptcha,
33
+ });
34
+ try {
35
+ await recaptchaManager.getRecaptchaWidget();
36
+ expect.fail('should not get here');
37
+ } catch (e) {
38
+ expect((e as Error).message).to.equal(
39
+ 'The reCaptcha widget requires a site key',
40
+ );
41
+ }
42
+ });
43
+
44
+ it('returns a cached version if one already exists for a given site key', async () => {
45
+ const mockGrecaptcha = new MockGrecaptcha({
46
+ mode: 'success',
47
+ });
48
+ mockGrecaptcha.response = 'foo';
49
+ const recaptchaManager = new RecaptchaManager({
50
+ lazyLoader: mockLazyLoader,
51
+ grecaptchaLibrary: mockGrecaptcha,
52
+ defaultSiteKey: '123',
53
+ });
54
+ const recaptcha1 = await recaptchaManager.getRecaptchaWidget();
55
+ const recaptcha2 = await recaptchaManager.getRecaptchaWidget();
56
+ expect(recaptcha1).to.equal(recaptcha2);
57
+ });
58
+
59
+ it('loads the recaptcha library if needed', async () => {
60
+ // Mock lazy loader that mimics the grecaptcha script calling the callback on load
61
+ const mockLazyLoaderWithCallback = new MockLazyLoaderService(() => {
62
+ window.grecaptcha = new MockGrecaptcha({
63
+ mode: 'success',
64
+ });
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
+ (window as any).grecaptchaLoadedCallback();
67
+ });
68
+
69
+ const recaptchaManager = new RecaptchaManager({
70
+ lazyLoader: mockLazyLoaderWithCallback,
71
+ defaultSiteKey: '123',
72
+ timeout: 100,
73
+ });
74
+
75
+ await recaptchaManager.getRecaptchaWidget();
76
+ const loadUrl = mockLazyLoaderWithCallback.loadScriptSrc;
77
+ expect(
78
+ loadUrl?.includes(
79
+ 'https://www.recaptcha.net/recaptcha/api.js?onload=grecaptchaLoadedCallback',
80
+ ),
81
+ ).to.be.true;
82
+ });
83
+
84
+ it('rejects after specified timeout if grecaptcha fails to execute callback', async () => {
85
+ const recaptchaManager = new RecaptchaManager({
86
+ lazyLoader: mockLazyLoader,
87
+ defaultSiteKey: '123',
88
+ timeout: 100,
89
+ });
90
+
91
+ try {
92
+ await recaptchaManager.getRecaptchaWidget();
93
+ expect.fail('recaptcha load did not time out as expected');
94
+ } catch (err) {
95
+ expect(err).to.be.instanceOf(Error);
96
+ expect((err as Error).message).to.equal(
97
+ 'grecaptcha failed to execute callback',
98
+ );
99
+ }
100
+ });
101
+
102
+ it('can set the timeout delay', async () => {
103
+ const recaptchaManager = new RecaptchaManager({
104
+ lazyLoader: mockLazyLoader,
105
+ defaultSiteKey: '123',
106
+ });
107
+
108
+ recaptchaManager.setTimeoutDelay(1);
109
+
110
+ try {
111
+ await recaptchaManager.getRecaptchaWidget();
112
+ expect.fail('recaptcha load did not time out as expected');
113
+ } catch (err) {
114
+ expect(err).to.be.instanceOf(Error);
115
+ expect((err as Error).message).to.equal(
116
+ 'grecaptcha failed to execute callback',
117
+ );
118
+ }
119
+ });
120
+ });
121
+
122
+ describe('ReCaptcha Widget', () => {
123
+ it('can error properly like a Promise', async () => {
124
+ const mockGrecaptcha = new MockGrecaptcha({
125
+ mode: 'error',
126
+ });
127
+ const recaptchaManager = new RecaptchaManager({
128
+ lazyLoader: mockLazyLoader,
129
+ grecaptchaLibrary: mockGrecaptcha,
130
+ defaultSiteKey: '123',
131
+ });
132
+ const recaptcha = await recaptchaManager.getRecaptchaWidget();
133
+
134
+ try {
135
+ await recaptcha.execute();
136
+ expect.fail('should not get here');
137
+ } catch (error) {
138
+ expect((error as Error).message).to.equal('error');
139
+ }
140
+ });
141
+
142
+ it('can expire properly like a Promise', async () => {
143
+ const mockGrecaptcha = new MockGrecaptcha({
144
+ mode: 'expired',
145
+ });
146
+ const recaptchaManager = new RecaptchaManager({
147
+ lazyLoader: mockLazyLoader,
148
+ grecaptchaLibrary: mockGrecaptcha,
149
+ defaultSiteKey: '123',
150
+ });
151
+ const recaptcha = await recaptchaManager.getRecaptchaWidget();
152
+
153
+ try {
154
+ await recaptcha.execute();
155
+ expect.fail('should not get here');
156
+ } catch (error) {
157
+ expect((error as Error).message).to.equal('expired');
158
+ }
159
+ });
160
+
161
+ it('resets the captcha after execution', async () => {
162
+ const mockGrecaptcha = new MockGrecaptcha({
163
+ mode: 'success',
164
+ addDelay: true,
165
+ });
166
+ const recaptchaManager = new RecaptchaManager({
167
+ lazyLoader: mockLazyLoader,
168
+ grecaptchaLibrary: mockGrecaptcha,
169
+ defaultSiteKey: '123',
170
+ });
171
+ const recaptcha = await recaptchaManager.getRecaptchaWidget();
172
+
173
+ expect(mockGrecaptcha.resetCallCount).to.equal(0);
174
+ await recaptcha.execute();
175
+ expect(mockGrecaptcha.resetCallCount).to.equal(1);
176
+ await recaptcha.execute();
177
+ expect(mockGrecaptcha.resetCallCount).to.equal(2);
178
+ });
179
+
180
+ // there's no way to know if the user has dismissed the captcha so if another execution
181
+ // comes through while the captcha is still active, it will be reset
182
+ it('resets the captcha if another execution gets called', async () => {
183
+ const mockGrecaptcha = new MockGrecaptcha({
184
+ mode: 'success',
185
+ addDelay: true,
186
+ });
187
+ const recaptchaManager = new RecaptchaManager({
188
+ lazyLoader: mockLazyLoader,
189
+ grecaptchaLibrary: mockGrecaptcha,
190
+ defaultSiteKey: '123',
191
+ });
192
+ const recaptcha = await recaptchaManager.getRecaptchaWidget();
193
+
194
+ expect(mockGrecaptcha.resetCallCount).to.equal(0);
195
+ recaptcha.execute();
196
+ expect(mockGrecaptcha.resetCallCount).to.equal(0);
197
+ await recaptcha.execute();
198
+ expect(mockGrecaptcha.resetCallCount).to.equal(2);
199
+ });
200
+ });
201
+ });
package/tsconfig.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "importHelpers": true,
13
- "outDir": "dist",
14
- "sourceMap": true,
15
- "inlineSources": true,
16
- "rootDir": "./",
17
- "declaration": true,
18
- "plugins": [
19
- {
20
- "name": "ts-lit-plugin"
21
- }
22
- ],
23
- "paths": {
24
- // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
- "rollup/parseAst": [
26
- "./node_modules/rollup/dist/parseAst"
27
- ]
28
- }
29
- },
30
- "include": ["**/*.ts"]
31
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ "plugins": [
19
+ {
20
+ "name": "ts-lit-plugin"
21
+ }
22
+ ],
23
+ "paths": {
24
+ // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
+ "rollup/parseAst": [
26
+ "./node_modules/rollup/dist/parseAst"
27
+ ]
28
+ }
29
+ },
30
+ "include": ["**/*.ts"]
31
+ }
@@ -1,32 +1,32 @@
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: '/demo',
9
- watch: !hmr,
10
- sslCert: './ssl/server.crt',
11
- sslKey: './ssl/server.key',
12
- hostname: 'local.archive.org',
13
- http2: true,
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- /** Configure bare import resolve plugin */
22
- // nodeResolve: {
23
- // exportConditions: ['browser', 'development']
24
- // },
25
-
26
- plugins: [
27
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
- ],
30
-
31
- // See documentation for all available options
32
- });
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: '/demo',
9
+ watch: !hmr,
10
+ sslCert: './ssl/server.crt',
11
+ sslKey: './ssl/server.key',
12
+ hostname: 'local.archive.org',
13
+ http2: true,
14
+
15
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
+ // esbuildTarget: 'auto'
17
+
18
+ /** Set appIndex to enable SPA routing */
19
+ // appIndex: 'demo/index.html',
20
+
21
+ /** Configure bare import resolve plugin */
22
+ // nodeResolve: {
23
+ // exportConditions: ['browser', 'development']
24
+ // },
25
+
26
+ plugins: [
27
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
+ ],
30
+
31
+ // See documentation for all available options
32
+ });