Skip to content

Commit 3f5734c

Browse files
authored
Merge pull request #2181 from oasisprotocol/lw/fix-parcel-upgrade-warnings
Fix warnings and error overlays since parcel@2.14
2 parents 7fa49ac + cfb5757 commit 3f5734c

31 files changed

Lines changed: 1272 additions & 1219 deletions

File tree

.changelog/2181.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix warnings and error overlays since parcel@2.14

extension/src/ExtLedgerAccessPopup/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '../../../src/utils/warnImportMapViolation'
12
import * as React from 'react'
23
import { createRoot } from 'react-dom/client'
34

extension/src/popup/popup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '../../../src/utils/warnImportMapViolation'
12
import React from 'react'
23
import { createRoot } from 'react-dom/client'
34
import { Provider } from 'react-redux'

internals/getSecurityHeaders.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ const hmr = `
1818
http://localhost:2222
1919
ws://localhost:2222
2020
`
21-
// If this changes csp-react-error-overlay.spec.ts will print a new sha in an error in csp-react-error-overlay.spec.ts.
22-
const reactErrorOverlay = `'sha256-yt+SNVxRkIi6H6yb7ndFuZM1esMX9esg3UpRHaTsyVk='`
2321
const hmrScripts = `
2422
'unsafe-eval'
2523
`
2624

25+
const warnImportMapViolation = async () => {
26+
const importMap = document.querySelector('script[type="importmap"]')
27+
if (!importMap) return
28+
const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(importMap.innerHTML))
29+
const cspHash = `sha256-${btoa(String.fromCharCode(...new Uint8Array(hash)))}`
30+
console.warn(
31+
`In dev mode parcel adds <script type="importmap">. CSP blocks executing this and shows it as violation '${cspHash}', but imports still work.`,
32+
)
33+
}
34+
2735
/**
2836
* Keep this synced with deployment headers
2937
*
@@ -34,8 +42,7 @@ const getCsp = ({ isExtension, isDev }) =>
3442
default-src 'none';
3543
script-src
3644
'self'
37-
${!isExtension && isDev ? reactErrorOverlay : '' /* Manifest v3 doesn't allow anything */}
38-
${!isExtension && isDev ? hmrScripts : ''}
45+
${!isExtension && isDev ? hmrScripts : '' /* Manifest v3 doesn't allow anything */}
3946
${!isExtension ? 'report-sample' : ''}
4047
;
4148
style-src
@@ -109,4 +116,4 @@ const getPermissionsPolicy = () =>
109116
.join(' ')
110117
.replace(/ ,/g, ',')
111118

112-
module.exports = { getCsp, getPermissionsPolicy, reactErrorOverlay }
119+
module.exports = { getCsp, getPermissionsPolicy, warnImportMapViolation }

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@
6666
"bip39": "3.1.0",
6767
"body-scroll-lock": "4.0.0-beta.0",
6868
"copy-to-clipboard": "3.3.3",
69-
"grommet": "2.36.1",
70-
"grommet-icons": "4.12.0",
69+
"grommet": "2.47.0",
70+
"grommet-icons": "4.12.4",
7171
"i18next": "23.6.0",
7272
"i18next-browser-languagedetector": "7.1.0",
7373
"lodash": "4.17.21",
7474
"qrcode.react": "3.2.0",
7575
"react": "18.3.1",
76-
"react-data-table-component": "6.11.8",
76+
"react-data-table-component": "7.7.0",
7777
"react-dom": "18.3.1",
7878
"react-helmet-async": "1.3.0",
7979
"react-i18next": "13.3.1",
@@ -148,7 +148,7 @@
148148
"@typescript-eslint/eslint-plugin": "6.9.1",
149149
"bip39": "3.1.0",
150150
"eslint-plugin-react": "7.37.4",
151-
"grommet-icons": "4.12.0",
151+
"grommet-icons": "4.12.4",
152152
"typescript": "5.2.2",
153153
"protobufjs": "7.2.5"
154154
},
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { test, expect } from '@playwright/test'
2-
import { reactErrorOverlay } from '../../internals/getSecurityHeaders.js'
32
import { expectNoErrorsInConsole } from '../utils/expectNoErrorsInConsole'
43

5-
test('Dev Content-Security-Policy should allow react-error-overlay', async ({ page, baseURL }) => {
4+
test('Dev Content-Security-Policy should allow @parcel/error-overlay', async ({ page, baseURL }) => {
65
if (baseURL !== 'http://localhost:3000') test.skip()
76
expect((await page.request.head('/')).headers()).toHaveProperty('content-security-policy')
8-
expect((await page.request.head('/')).headers()['content-security-policy']).toContain(reactErrorOverlay)
97
await page.goto('/e2e')
108
await page.getByRole('button', { name: 'Trigger uncaught error' }).click()
119
await expectNoErrorsInConsole(page)
12-
await expect(page.locator('iframe')).toBeVisible()
13-
await expect(page.frameLocator('iframe').getByText('ReferenceError')).toBeVisible()
10+
await expect(page.getByText('ReferenceError')).toBeVisible({ timeout: 30_000 })
1411
})

src/app/components/AddressBox/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`<AddressBox /> should render address properly 1`] = `
4-
.c3 {
5-
display: inline-block;
6-
-webkit-flex: 0 0 auto;
7-
-ms-flex: 0 0 auto;
8-
flex: 0 0 auto;
9-
width: 18px;
10-
height: 18px;
11-
fill: #666666;
12-
stroke: #666666;
13-
}
14-
15-
.c3 g {
16-
fill: inherit;
17-
stroke: inherit;
18-
}
19-
20-
.c3 *:not([stroke])[fill='none'] {
21-
stroke-width: 0;
22-
}
23-
24-
.c3 *[stroke*='#'],
25-
.c3 *[STROKE*='#'] {
26-
stroke: inherit;
27-
fill: none;
28-
}
29-
30-
.c3 *[fill-rule],
31-
.c3 *[FILL-RULE],
32-
.c3 *[fill*='#'],
33-
.c3 *[FILL*='#'] {
34-
fill: inherit;
35-
stroke: none;
36-
}
37-
384
.c0 {
395
display: -webkit-box;
406
display: -webkit-flex;
@@ -95,6 +61,40 @@ exports[`<AddressBox /> should render address properly 1`] = `
9561
flex: 1 1;
9662
}
9763
64+
.c3 {
65+
display: inline-block;
66+
-webkit-flex: 0 0 auto;
67+
-ms-flex: 0 0 auto;
68+
flex: 0 0 auto;
69+
width: 18px;
70+
height: 18px;
71+
fill: #666666;
72+
stroke: #666666;
73+
}
74+
75+
.c3 g {
76+
fill: inherit;
77+
stroke: inherit;
78+
}
79+
80+
.c3 *:not([stroke])[fill='none'] {
81+
stroke-width: 0;
82+
}
83+
84+
.c3 *[stroke*='#'],
85+
.c3 *[STROKE*='#'] {
86+
stroke: inherit;
87+
fill: none;
88+
}
89+
90+
.c3 *[fill-rule],
91+
.c3 *[FILL-RULE],
92+
.c3 *[fill*='#'],
93+
.c3 *[FILL*='#'] {
94+
fill: inherit;
95+
stroke: none;
96+
}
97+
9898
.c5 {
9999
font-size: inherit;
100100
line-height: normal;
@@ -230,74 +230,6 @@ exports[`<AddressBox /> should render address properly 1`] = `
230230
`;
231231

232232
exports[`<EditableNameBox /> should render name properly 1`] = `
233-
.c6 {
234-
display: inline-block;
235-
-webkit-flex: 0 0 auto;
236-
-ms-flex: 0 0 auto;
237-
flex: 0 0 auto;
238-
width: 16px;
239-
height: 16px;
240-
fill: link;
241-
stroke: link;
242-
}
243-
244-
.c6 g {
245-
fill: inherit;
246-
stroke: inherit;
247-
}
248-
249-
.c6 *:not([stroke])[fill='none'] {
250-
stroke-width: 0;
251-
}
252-
253-
.c6 *[stroke*='#'],
254-
.c6 *[STROKE*='#'] {
255-
stroke: inherit;
256-
fill: none;
257-
}
258-
259-
.c6 *[fill-rule],
260-
.c6 *[FILL-RULE],
261-
.c6 *[fill*='#'],
262-
.c6 *[FILL*='#'] {
263-
fill: inherit;
264-
stroke: none;
265-
}
266-
267-
.c10 {
268-
display: inline-block;
269-
-webkit-flex: 0 0 auto;
270-
-ms-flex: 0 0 auto;
271-
flex: 0 0 auto;
272-
width: 18px;
273-
height: 18px;
274-
fill: #666666;
275-
stroke: #666666;
276-
}
277-
278-
.c10 g {
279-
fill: inherit;
280-
stroke: inherit;
281-
}
282-
283-
.c10 *:not([stroke])[fill='none'] {
284-
stroke-width: 0;
285-
}
286-
287-
.c10 *[stroke*='#'],
288-
.c10 *[STROKE*='#'] {
289-
stroke: inherit;
290-
fill: none;
291-
}
292-
293-
.c10 *[fill-rule],
294-
.c10 *[FILL-RULE],
295-
.c10 *[fill*='#'],
296-
.c10 *[FILL*='#'] {
297-
fill: inherit;
298-
stroke: none;
299-
}
300-
301233
.c0 {
302234
display: -webkit-box;
303235
display: -webkit-flex;
@@ -389,6 +321,74 @@ exports[`<EditableNameBox /> should render name properly 1`] = `
389321
flex-direction: column;
390322
}
391323
324+
.c6 {
325+
display: inline-block;
326+
-webkit-flex: 0 0 auto;
327+
-ms-flex: 0 0 auto;
328+
flex: 0 0 auto;
329+
width: 16px;
330+
height: 16px;
331+
fill: link;
332+
stroke: link;
333+
}
334+
335+
.c6 g {
336+
fill: inherit;
337+
stroke: inherit;
338+
}
339+
340+
.c6 *:not([stroke])[fill='none'] {
341+
stroke-width: 0;
342+
}
343+
344+
.c6 *[stroke*='#'],
345+
.c6 *[STROKE*='#'] {
346+
stroke: inherit;
347+
fill: none;
348+
}
349+
350+
.c6 *[fill-rule],
351+
.c6 *[FILL-RULE],
352+
.c6 *[fill*='#'],
353+
.c6 *[FILL*='#'] {
354+
fill: inherit;
355+
stroke: none;
356+
}
357+
358+
.c10 {
359+
display: inline-block;
360+
-webkit-flex: 0 0 auto;
361+
-ms-flex: 0 0 auto;
362+
flex: 0 0 auto;
363+
width: 18px;
364+
height: 18px;
365+
fill: #666666;
366+
stroke: #666666;
367+
}
368+
369+
.c10 g {
370+
fill: inherit;
371+
stroke: inherit;
372+
}
373+
374+
.c10 *:not([stroke])[fill='none'] {
375+
stroke-width: 0;
376+
}
377+
378+
.c10 *[stroke*='#'],
379+
.c10 *[STROKE*='#'] {
380+
stroke: inherit;
381+
fill: none;
382+
}
383+
384+
.c10 *[fill-rule],
385+
.c10 *[FILL-RULE],
386+
.c10 *[fill*='#'],
387+
.c10 *[FILL*='#'] {
388+
fill: inherit;
389+
stroke: none;
390+
}
391+
392392
.c4 {
393393
font-size: inherit;
394394
line-height: normal;

0 commit comments

Comments
 (0)