Skip to content

Commit

Permalink
improve manifest type (#1751)
Browse files Browse the repository at this point in the history
* improve manifest type

* changeset

* lint

---------

Co-authored-by: turbocrime <[email protected]>
  • Loading branch information
turbocrime and turbocrime authored Aug 31, 2024
1 parent 5616a7a commit a3bef37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-cows-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@penumbra-zone/client': minor
---

improve manifest type
6 changes: 3 additions & 3 deletions apps/minifront/src/components/header/menu/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ProviderMenu = () => {
id='provider-icon'
className={cn('w-[1.5em]', 'max-w-none', 'h-[1.5em]')}
src={URL.createObjectURL(penumbra.manifest.icons['128'])}
alt={`${penumbra.manifest['name']} Icon`}
alt={`${penumbra.manifest.name} Icon`}
/>
{chainId}
</NavigationMenu.Trigger>
Expand All @@ -43,9 +43,9 @@ export const ProviderMenu = () => {
<NavigationMenu.Link className={cn(...linkStyle, 'p-0', 'leading-normal')}>
<div className='ml-4 text-muted-foreground'>
<span className='font-headline text-muted'>
{penumbra.manifest['name']} {penumbra.manifest['version']}
{penumbra.manifest.name} {penumbra.manifest.version}
</span>
<p>{penumbra.manifest['description']}</p>
<p>{penumbra.manifest.description}</p>
</div>
</NavigationMenu.Link>
</NavigationMenu.Item>
Expand Down
11 changes: 7 additions & 4 deletions packages/client/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
*
* @see https://web.archive.org/web/20120606044635/http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-your-private-key-233
*/
export type PenumbraManifestJson = Partial<chrome.runtime.ManifestV3> &
Required<Pick<chrome.runtime.ManifestV3, 'name' | 'version' | 'description' | 'icons'>>;
export type PenumbraManifestJson = chrome.runtime.ManifestV3 & {
[k in 'name' | 'version' | 'description' | 'icons']-?: NonNullable<chrome.runtime.ManifestV3[k]>;
};

type IconBlobs = { [size in `${number}`]?: Blob } & { [size128 in `${128}`]-?: NonNullable<Blob> };

export type PenumbraManifest = Omit<PenumbraManifestJson, 'icons'> & {
['icons']: { '128': Blob } & Record<`${number}`, Blob>;
export type PenumbraManifest = {
[k in keyof PenumbraManifestJson]: k extends 'icons' ? IconBlobs : PenumbraManifestJson[k];
};

export const isPenumbraManifestJson = (mf: unknown): mf is PenumbraManifestJson =>
Expand Down

0 comments on commit a3bef37

Please sign in to comment.