Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Add display_override types & validation #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ declare class WebpackPwaManifest extends Plugin {
declare namespace WebpackPwaManifest {
type Direction = 'ltr' | 'rtl' | 'auto';
type Display = 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser';
type DisplayOverride = 'window-controls-overlay' | Display;
type Orientation = 'any' | 'natural' | 'landscape' | 'landscape-primary' | 'landscape-secondary' | 'portrait' | 'portrait-primary' | 'portrait-secondary';
type CrossOrigin = 'use-credentials' | 'anonymous';
interface ManifestOptions {
background_color?: string;
description?: string;
dir?: Direction;
display?: Display;
display_override?: DisplayOverride[];
fingerprints?: boolean;
filename?: string;
icons?: Icon | Icon[];
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import checkDeprecated from './validators/versioning'

class WebpackPwaManifest {
constructor (options = {}) {
validatePresets(options, 'dir', 'display', 'orientation', 'crossorigin')
validatePresets(options, 'dir', 'display', 'display_override', 'orientation', 'crossorigin')
validateColors(options, 'background_color', 'theme_color')
checkDeprecated(options, 'useWebpackPublicPath')
this._generator = null
Expand Down
4 changes: 4 additions & 0 deletions src/validators/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ const presets = {
display: [
'fullscreen', 'standalone', 'minimal-ui', 'browser'
],
display_override: [
'window-controls-overlay', 'fullscreen', 'standalone', 'minimal-ui', 'browser'
],
crossorigin: [
'anonymous', 'use-credentials'
]
}

function hasPreset (key, value) {
if (Array.isArray(value)) return value.every(v => hasPreset(key, v))
return presets[key].indexOf(value) >= 0
}

Expand Down