Skip to content

Commit aa07862

Browse files
CodingDiveuserquin
andauthored
fix: add origin to scope_extensions to comply with the spec and get rid of warning (#880)
* fix: add origin to scope_extensions to comply with the spec and get rid of warning * fix: address feedback of @userquin * fix: move jsdoc to inside the scope_extensions * fix: remove spaces in jsdoc comment * chore: lint + simplify type --------- Co-authored-by: userquin <userquin@gmail.com>
1 parent 8247192 commit aa07862

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/options.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ export async function resolveOptions(ctx: PWAPluginContext): Promise<ResolvedVit
176176
}
177177
})
178178
}
179+
180+
if (manifest.scope_extensions) {
181+
manifest.scope_extensions = manifest.scope_extensions.map((scopeExtension) => {
182+
return {
183+
origin: scopeExtension.origin,
184+
type: scopeExtension.type ?? 'origin',
185+
}
186+
})
187+
}
179188
}
180189

181190
const {

src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ interface Nothing {}
458458
*/
459459
export type StringLiteralUnion<T extends U, U = string> = T | (U & Nothing)
460460

461+
export type ScopeExtensionsType = 'origin'
462+
461463
/**
462464
* @see https://w3c.github.io/manifest/#manifest-image-resources
463465
*/
@@ -629,12 +631,18 @@ export interface ManifestOptions {
629631
edge_side_panel?: {
630632
preferred_width?: number
631633
}
634+
632635
/**
633636
* @see https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md
637+
* @see https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/scope_extensions
634638
* @default []
635639
*/
636640
scope_extensions: {
637641
origin: string
642+
/**
643+
* @default 'origin'
644+
*/
645+
type?: StringLiteralUnion<ScopeExtensionsType>
638646
}[]
639647
}
640648

0 commit comments

Comments
 (0)